From 660e7e6a5182f79806938a9a0782647927e4f896 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 20 Sep 2026 14:50:02 +1000 Subject: [PATCH 01/55] Discovery available packs up-front (#1) - Available packs are discovered up-front to cull existance checks of evicted packs - Manifest lookup ordered by creation date so new entries are included when over max manifests limit. - Truncation of discovered manifests is now reported in metrics (boolean). - If cache entries are skipped due to prefix mismatch (indicating GH API acting out of spec), it is logged. Previously silently ignored. --- README.md | 9 +++- action.yml | 2 +- action/post.js | 3 ++ cmd/cache-server/main.go | 4 +- internal/cache/catalog.go | 78 ++++++++++++++++++++-------- internal/cache/catalog_test.go | 61 +++++++++++++++++++--- internal/server/manifest.go | 10 +++- internal/server/pack_store.go | 82 +++++++++++++++++++++++++++--- internal/server/pack_store_test.go | 68 +++++++++++++++++++++++-- internal/server/server_test.go | 8 +++ internal/server/stats.go | 9 ++++ 11 files changed, 290 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 51a1f30..c2d638d 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,13 @@ manifest a child of every head they observed. Parallel writers can therefore publish siblings without overwriting each other. Readers discover and merge all heads. If two manifests contain different Action Results for the same action digest, that digest is treated as a cache miss rather than picking one result. + +Discovery makes two listings: a bounded one for manifests, honouring +`max-manifests` and newest first, and an unbounded one for packs. A manifest can +outlive the pack it references, because GitHub evicts entries independently. +When the pack listing shows that a pack is gone, its entries are resolved as +ordinary cache misses without attempting a download; `packs_discovered` and +`pack_loads_skipped` report that in the final statistics. Manifest discovery is eventually consistent by design: an unseen manifest is only a temporary miss. @@ -131,7 +138,7 @@ Do not enable Bazel remote-cache compression with this release. | `storage-mode` | `objects` | `objects` (v0.2) or `packs` (CARv2 and manifest DAG) | | `pack-size-mb` | `8` | Target size for a CARv2 archive; only for `packs`, 1–32 MiB | | `pack-flush-seconds` | `30` | Maximum local staging interval; only for `packs` | -| `max-manifests` | `2048` | Bound on REST-discovered immutable manifests; only for `packs` | +| `max-manifests` | `2048` | Maximum manifests downloaded during discovery; only for `packs` | | `github-token` | `${{ github.token }}` | `actions: read` token for packed-manifest discovery | | `max-blob-size-mb` | `512` | Maximum spooled upload/download size | | `max-concurrent-operations` | `4` | Backend-operation backpressure | diff --git a/action.yml b/action.yml index c462575..0042b73 100644 --- a/action.yml +++ b/action.yml @@ -30,7 +30,7 @@ inputs: required: false default: "30" max-manifests: - description: "Maximum immutable manifest entries to discover through the GitHub Actions REST API" + description: "Maximum manifests to download during discovery; any beyond this are ignored and become cache misses" required: false default: "2048" github-token: diff --git a/action/post.js b/action/post.js index 9efabf8..32d4d33 100644 --- a/action/post.js +++ b/action/post.js @@ -74,7 +74,10 @@ async function post() { `| CARv2 pack uploads | ${stats.pack_uploads ?? 0} |`, `| Manifest uploads | ${stats.manifest_uploads ?? 0} |`, `| CARv2 pack downloads | ${stats.pack_downloads ?? 0} |`, + `| Unavailable packs skipped | ${stats.pack_loads_skipped ?? 0} |`, + `| Packs discovered | ${stats.packs_discovered ?? 0} |`, `| Manifests discovered | ${stats.manifests_discovered ?? 0} |`, + `| Manifest discovery truncated | ${stats.manifest_discovery_truncated ? "yes" : "no"} |`, `| Action-digest conflicts | ${stats.action_digest_conflicts ?? 0} |`, `| Read-only discarded uploads | ${stats.discarded_uploads ?? 0} |`, `| Backend downloads | ${stats.backend_downloads ?? 0} |`, diff --git a/cmd/cache-server/main.go b/cmd/cache-server/main.go index daedc43..8b7bfa3 100644 --- a/cmd/cache-server/main.go +++ b/cmd/cache-server/main.go @@ -43,7 +43,7 @@ func run() error { storageMode = flag.String("storage-mode", "objects", "storage mode: objects or packs") packSize = flag.Int64("pack-size", 8*1024*1024, "target CARv2 pack size in bytes") packFlush = flag.Duration("pack-flush-interval", 30*time.Second, "maximum delay before flushing pending CARv2 data") - maxManifests = flag.Int("max-manifests", 2048, "maximum manifest cache entries to discover") + maxManifests = flag.Int("max-manifests", 2048, "maximum manifests to read during discovery; any beyond this are ignored") writeEnabled = flag.Bool("write-enabled", false, "publish validated uploads") failOpen = flag.Bool("fail-open", true, "degrade backend errors to misses/success") maxBlobSize = flag.Int64("max-blob-size", 512*1024*1024, "maximum object size in bytes") @@ -91,7 +91,7 @@ func run() error { logger := log.New(os.Stderr, "bazel-gha-cache: ", log.LstdFlags|log.LUTC) var catalog cache.Catalog if *storageMode == "packs" { - catalog, err = cache.NewActionsCatalog(*backendTimeout) + catalog, err = cache.NewActionsCatalog(*backendTimeout, logger) if err != nil { return err } diff --git a/internal/cache/catalog.go b/internal/cache/catalog.go index 2cb711f..b03057e 100644 --- a/internal/cache/catalog.go +++ b/internal/cache/catalog.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "net/http" "net/url" "os" @@ -14,12 +15,21 @@ import ( ) // Catalog lists immutable GitHub Actions cache keys. The packed backend uses -// it solely to discover manifest heads; cache bytes are still restored through -// the runner cache-v2 service. +// it to discover manifest heads and to learn which packs still exist; cache +// bytes are still restored through the runner cache-v2 service. Listing reads +// metadata only, so it does not extend an entry's lifetime. type Catalog interface { - List(ctx context.Context, keyPrefix string, limit int) ([]string, error) + // List returns cache keys starting with keyPrefix, newest first. A positive + // limit stops the listing early and reports truncation; UnboundedListing + // returns every matching key. + List(ctx context.Context, keyPrefix string, limit int) (keys []string, truncated bool, err error) } +// UnboundedListing lists every matching key. Use it only where a missing key +// changes a decision, because a truncated listing would silently look like +// absence. +const UnboundedListing = 0 + // ActionsCatalog lists cache metadata through the public GitHub REST API. // A normal GITHUB_TOKEN with actions: read is sufficient. It deliberately // does not expose deletion or mutation operations. @@ -28,11 +38,12 @@ type ActionsCatalog struct { repository string token string client *http.Client + logger *log.Logger } // NewActionsCatalog creates a manifest-discovery client from GitHub Actions // runner environment variables. -func NewActionsCatalog(timeout time.Duration) (*ActionsCatalog, error) { +func NewActionsCatalog(timeout time.Duration, logger *log.Logger) (*ActionsCatalog, error) { repository := os.Getenv("GITHUB_REPOSITORY") if len(strings.Split(repository, "/")) != 2 || strings.HasPrefix(repository, "/") || strings.HasSuffix(repository, "/") { return nil, errors.New("GITHUB_REPOSITORY must be owner/repository for packed-cache manifest discovery") @@ -54,6 +65,7 @@ func NewActionsCatalog(timeout time.Duration) (*ActionsCatalog, error) { repository: repository, token: token, client: &http.Client{Timeout: timeout}, + logger: logger, }, nil } @@ -63,55 +75,81 @@ type actionsCacheListResponse struct { } `json:"actions_caches"` } -// List returns at most limit cache keys whose immutable key starts with -// keyPrefix. GitHub's API pagination is followed explicitly so a later writer -// does not silently hide older DAG parents. -func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) ([]string, error) { - if limit <= 0 { - return nil, errors.New("catalog list limit must be positive") - } +// List returns cache keys whose immutable key starts with keyPrefix, newest +// first, and reports whether a positive limit truncated the result. GitHub's +// API pagination is followed explicitly so a later writer does not silently +// hide older DAG parents. +func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) ([]string, bool, error) { page := 1 keys := make([]string, 0) + unexpected := 0 for { endpoint := *c.baseURL endpoint.Path = strings.TrimRight(endpoint.Path, "/") + "/repos/" + c.repository + "/actions/caches" query := endpoint.Query() query.Set("key", keyPrefix) + // Newest first, so a truncated listing keeps the most recent entries + // instead of an arbitrary subset. + query.Set("sort", "created_at") + query.Set("direction", "desc") query.Set("per_page", "100") query.Set("page", strconv.Itoa(page)) endpoint.RawQuery = query.Encode() request, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil) if err != nil { - return nil, fmt.Errorf("create cache catalog request: %w", err) + return nil, false, fmt.Errorf("create cache catalog request: %w", err) } request.Header.Set("Accept", "application/vnd.github+json") request.Header.Set("Authorization", "Bearer "+c.token) request.Header.Set("X-GitHub-Api-Version", "2022-11-28") response, err := c.client.Do(request) if err != nil { - return nil, fmt.Errorf("list GitHub Actions caches: %w", err) + return nil, false, fmt.Errorf("list GitHub Actions caches: %w", err) } var result actionsCacheListResponse decodeErr := json.NewDecoder(response.Body).Decode(&result) _ = response.Body.Close() if response.StatusCode != http.StatusOK { - return nil, fmt.Errorf("list GitHub Actions caches: HTTP %d", response.StatusCode) + return nil, false, fmt.Errorf("list GitHub Actions caches: HTTP %d", response.StatusCode) } if decodeErr != nil { - return nil, fmt.Errorf("decode GitHub Actions cache list: %w", decodeErr) + return nil, false, fmt.Errorf("decode GitHub Actions cache list: %w", decodeErr) } for _, entry := range result.ActionsCaches { - if strings.HasPrefix(entry.Key, keyPrefix) { - keys = append(keys, entry.Key) - if len(keys) > limit { - return nil, fmt.Errorf("manifest catalog exceeds configured limit of %d entries", limit) + if !strings.HasPrefix(entry.Key, keyPrefix) { + // GitHub documents key as an explicit key or prefix, so a + // non-matching entry means the filter no longer behaves as this + // catalog assumes. + if unexpected == 0 { + c.logf("GitHub cache listing for prefix %q returned unrelated key %q", keyPrefix, entry.Key) } + unexpected++ + continue + } + if limit > UnboundedListing && len(keys) == limit { + c.reportUnexpected(keyPrefix, unexpected) + return keys, true, nil } + keys = append(keys, entry.Key) } if len(result.ActionsCaches) < 100 { - return keys, nil + c.reportUnexpected(keyPrefix, unexpected) + return keys, false, nil } page++ } } + +func (c *ActionsCatalog) reportUnexpected(keyPrefix string, unexpected int) { + if unexpected > 1 { + c.logf("GitHub cache listing for prefix %q returned %d unrelated keys", keyPrefix, unexpected) + } +} + +func (c *ActionsCatalog) logf(format string, args ...any) { + if c.logger == nil { + return + } + c.logger.Printf(format, args...) +} diff --git a/internal/cache/catalog_test.go b/internal/cache/catalog_test.go index d6715f9..f069f9a 100644 --- a/internal/cache/catalog_test.go +++ b/internal/cache/catalog_test.go @@ -1,7 +1,9 @@ package cache import ( + "bytes" "context" + "log" "net/http" "net/http/httptest" "net/url" @@ -19,6 +21,12 @@ func TestActionsCatalogListsAllPagesWithinPrefix(t *testing.T) { if got := r.URL.Query().Get("key"); got != "prefix-manifest-" { t.Fatalf("key = %q", got) } + if got := r.URL.Query().Get("sort"); got != "created_at" { + t.Fatalf("sort = %q", got) + } + if got := r.URL.Query().Get("direction"); got != "desc" { + t.Fatalf("direction = %q", got) + } if r.URL.Query().Get("page") == "1" { _, _ = w.Write([]byte(`{"actions_caches":[{"key":"prefix-manifest-one"}]}`)) return @@ -31,16 +39,16 @@ func TestActionsCatalogListsAllPagesWithinPrefix(t *testing.T) { t.Fatal(err) } catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} - keys, err := catalog.List(context.Background(), "prefix-manifest-", 10) + keys, truncated, err := catalog.List(context.Background(), "prefix-manifest-", 10) if err != nil { t.Fatal(err) } - if strings.Join(keys, ",") != "prefix-manifest-one" || requests != 1 { - t.Fatalf("keys/requests = %v/%d", keys, requests) + if strings.Join(keys, ",") != "prefix-manifest-one" || truncated || requests != 1 { + t.Fatalf("keys/truncated/requests = %v/%t/%d", keys, truncated, requests) } } -func TestActionsCatalogRejectsLimitOverflow(t *testing.T) { +func TestActionsCatalogTruncatesAtLimitAndListsUnbounded(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"actions_caches":[{"key":"prefix-one"},{"key":"prefix-two"}]}`)) })) @@ -50,7 +58,48 @@ func TestActionsCatalogRejectsLimitOverflow(t *testing.T) { t.Fatal(err) } catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} - if _, err := catalog.List(context.Background(), "prefix-", 1); err == nil { - t.Fatal("overflow was accepted") + keys, truncated, err := catalog.List(context.Background(), "prefix-", 1) + if err != nil { + t.Fatal(err) + } + if strings.Join(keys, ",") != "prefix-one" || !truncated { + t.Fatalf("bounded keys/truncated = %v/%t", keys, truncated) + } + keys, truncated, err = catalog.List(context.Background(), "prefix-", UnboundedListing) + if err != nil { + t.Fatal(err) + } + if strings.Join(keys, ",") != "prefix-one,prefix-two" || truncated { + t.Fatalf("unbounded keys/truncated = %v/%t", keys, truncated) + } +} + +func TestActionsCatalogLogsKeysOutsideTheRequestedPrefix(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(`{"actions_caches":[{"key":"prefix-one"},{"key":"unrelated"},{"key":"another"}]}`)) + })) + defer server.Close() + baseURL, err := url.Parse(server.URL) + if err != nil { + t.Fatal(err) + } + var logged bytes.Buffer + catalog := &ActionsCatalog{ + baseURL: baseURL, + repository: "owner/repository", + token: "token", + client: server.Client(), + logger: log.New(&logged, "", 0), + } + keys, _, err := catalog.List(context.Background(), "prefix-", UnboundedListing) + if err != nil { + t.Fatal(err) + } + if strings.Join(keys, ",") != "prefix-one" { + t.Fatalf("keys = %v", keys) + } + if !strings.Contains(logged.String(), `unrelated key "unrelated"`) || + !strings.Contains(logged.String(), "returned 2 unrelated keys") { + t.Fatalf("prefix filter violation was not reported: %q", logged.String()) } } diff --git a/internal/server/manifest.go b/internal/server/manifest.go index c53fb55..147d2f0 100644 --- a/internal/server/manifest.go +++ b/internal/server/manifest.go @@ -514,12 +514,18 @@ func validCID(value string) bool { return err == nil } +// carKeyPrefix is the namespace shared by pack and manifest keys, so a single +// catalog listing can enumerate both. +func carKeyPrefix(prefix string) string { + return prefix + "-car-" +} + func packKeyFor(prefix, id string) string { - return prefix + "-car-pack-v1-" + id + return carKeyPrefix(prefix) + "pack-v1-" + id } func manifestKeyFor(prefix, id string) string { - return prefix + "-car-manifest-v1-" + id + return carKeyPrefix(prefix) + "manifest-v1-" + id } func stringsHasSuffix(value, suffix string) bool { diff --git a/internal/server/pack_store.go b/internal/server/pack_store.go index f82c68a..2317bc9 100644 --- a/internal/server/pack_store.go +++ b/internal/server/pack_store.go @@ -45,6 +45,9 @@ type packStore struct { pendingBytes int64 loadedPacks map[string]string loadingPacks map[string]*packLoad + listedPacks map[string]struct{} + packsListed bool + missingPacks map[string]struct{} flushRequests chan struct{} stop chan struct{} @@ -64,6 +67,11 @@ type packLoad struct { err error } +// errPackUnavailable marks a permanent answer about an immutable pack key: +// evicted, out of this job's cache scope, or corrupt. It is a cache miss rather +// than a backend outage, and it is never worth retrying within a job. +var errPackUnavailable = errors.New("pack is unavailable") + func newPackStore(server *Server) (*packStore, error) { if server.cfg.Catalog == nil { return nil, errors.New("packed storage mode requires a manifest catalog") @@ -84,6 +92,8 @@ func newPackStore(server *Server) (*packStore, error) { pendingActions: make(map[string]pendingAction), loadedPacks: make(map[string]string), loadingPacks: make(map[string]*packLoad), + listedPacks: make(map[string]struct{}), + missingPacks: make(map[string]struct{}), flushRequests: make(chan struct{}, 1), stop: make(chan struct{}), } @@ -220,6 +230,9 @@ func (p *packStore) resolve(ctx context.Context, key, kind, digest string) (obje path, err := p.loadPack(ctx, packID) if err != nil { + if errors.Is(err, errPackUnavailable) { + return object{}, false, nil + } return object{}, false, err } data, err := readCARBlock(ctx, path, contentCID, p.server.cfg.MaxBlobSize) @@ -303,7 +316,22 @@ func (p *packStore) loadPack(ctx context.Context, packID string) (string, error) descriptor, exists := p.packs[packID] if !exists { p.mu.Unlock() - return "", fmt.Errorf("manifest references unavailable pack %s", packID) + return "", fmt.Errorf("manifest references unknown pack %s: %w", packID, errPackUnavailable) + } + if _, unavailable := p.missingPacks[packID]; unavailable { + p.mu.Unlock() + p.server.stats.packLoadsSkipped.Add(1) + return "", fmt.Errorf("pack %s is not restorable in this job: %w", packID, errPackUnavailable) + } + // The catalog lists every ref, so a pack absent from it is definitely gone. + // A listed pack may still be out of this job's cache scope, which only a + // failed download can reveal. + if _, listed := p.listedPacks[packID]; p.packsListed && !listed { + p.missingPacks[packID] = struct{}{} + p.mu.Unlock() + p.server.stats.packLoadsSkipped.Add(1) + p.server.cfg.Logger.Printf("pack %s is absent from the cache listing; its entries are cache misses", packID) + return "", fmt.Errorf("pack %s is not restorable in this job: %w", packID, errPackUnavailable) } loading := &packLoad{done: make(chan struct{})} p.loadingPacks[packID] = loading @@ -315,6 +343,10 @@ func (p *packStore) loadPack(ctx context.Context, packID string) (string, error) p.loadedPacks[packID] = path loading.path = path } + if errors.Is(err, errPackUnavailable) { + p.missingPacks[packID] = struct{}{} + p.server.cfg.Logger.Printf("pack %s cannot be restored; its entries are cache misses: %s", packID, safeError(err)) + } loading.err = err delete(p.loadingPacks, packID) close(loading.done) @@ -343,7 +375,7 @@ func (p *packStore) downloadPack(ctx context.Context, descriptor packDescriptor) return "", err } if !found { - return "", fmt.Errorf("pack %s is missing", descriptor.ID) + return "", fmt.Errorf("pack %s is missing: %w", descriptor.ID, errPackUnavailable) } p.server.stats.backendDownloads.Add(1) p.server.stats.packDownloads.Add(1) @@ -352,7 +384,7 @@ func (p *packStore) downloadPack(ctx context.Context, descriptor packDescriptor) return "", err } if info.Size() != descriptor.Size { - return "", fmt.Errorf("pack %s has size %d; manifest declares %d", descriptor.ID, info.Size(), descriptor.Size) + return "", fmt.Errorf("pack %s has size %d; manifest declares %d: %w", descriptor.ID, info.Size(), descriptor.Size, errPackUnavailable) } verify, err := os.Open(path) if err != nil { @@ -367,7 +399,7 @@ func (p *packStore) downloadPack(ctx context.Context, descriptor packDescriptor) return "", closeErr } if actual != descriptor.ID { - return "", fmt.Errorf("pack integrity check failed: expected %s, got %s", descriptor.ID, actual) + return "", fmt.Errorf("pack integrity check failed: expected %s, got %s: %w", descriptor.ID, actual, errPackUnavailable) } return path, nil } @@ -403,6 +435,7 @@ func (p *packStore) flushOneLocked(ctx context.Context) (bool, error) { return false, fmt.Errorf("publish CARv2 pack: %w", err) } p.server.stats.packUploads.Add(1) + p.listedPacks[pack.ID] = struct{}{} manifestValue := p.manifestForPackLocked(pack, entries, selectedCAS) manifestData, manifestID, err := encodeManifest(manifestValue) @@ -632,14 +665,38 @@ func filterPending[T any](order []string, values map[string]T) []string { } func (p *packStore) discover(ctx context.Context) error { - keys, err := p.catalog.List(ctx, manifestKeyFor(p.keyPrefix, ""), p.maxManifests) + // Listing reads metadata only: unlike a download it does not extend an + // entry's lifetime. Manifests are listed first, so the pack listing below + // cannot miss a pack that a concurrent writer published before its + // manifest. + manifestKeys, truncated, err := p.catalog.List(ctx, manifestKeyFor(p.keyPrefix, ""), p.maxManifests) + if err != nil { + return err + } + p.server.stats.manifestsDiscovered.Add(uint64(len(manifestKeys))) + if truncated { + p.server.stats.manifestDiscoveryTruncated.Store(true) + p.server.cfg.Logger.Printf( + "manifest discovery stopped at the max-manifests limit of %d; older manifests are treated as cache misses", + p.maxManifests) + } + // Packs are only witnessed, never read, during discovery. A truncated pack + // listing would look like eviction and suppress valid downloads, so it is + // bounded by the repository rather than by max-manifests. + packKeys, _, err := p.catalog.List(ctx, packKeyFor(p.keyPrefix, ""), cache.UnboundedListing) if err != nil { return err } - p.server.stats.manifestsDiscovered.Add(uint64(len(keys))) - manifests := make(map[string]manifest, len(keys)) + for _, key := range packKeys { + if id, ok := parsePackKey(p.keyPrefix, key); ok { + p.listedPacks[id] = struct{}{} + } + } + p.packsListed = true + p.server.stats.packsDiscovered.Add(uint64(len(p.listedPacks))) + manifests := make(map[string]manifest, len(manifestKeys)) parents := make(map[string]struct{}) - for _, key := range keys { + for _, key := range manifestKeys { manifestID, ok := parseManifestKey(p.keyPrefix, key) if !ok { continue @@ -726,6 +783,15 @@ func parseManifestKey(prefix, key string) (string, bool) { return id, validCID(id) } +func parsePackKey(prefix, key string) (string, bool) { + head := packKeyFor(prefix, "") + if len(key) <= len(head) || key[:len(head)] != head { + return "", false + } + id := key[len(head):] + return id, digestPattern.MatchString(id) +} + const rawCIDSectionOverheadBytes = 64 func readCARBlock(ctx context.Context, path, contentCID string, maxBlobSize int64) ([]byte, error) { diff --git a/internal/server/pack_store_test.go b/internal/server/pack_store_test.go index c84fab2..dfabcec 100644 --- a/internal/server/pack_store_test.go +++ b/internal/server/pack_store_test.go @@ -16,7 +16,7 @@ type memoryCatalog struct { backend *memoryBackend } -func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]string, error) { +func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]string, bool, error) { c.backend.mu.Lock() defer c.backend.mu.Unlock() keys := make([]string, 0) @@ -26,10 +26,10 @@ func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]stri } } sort.Strings(keys) - if len(keys) > limit { - return nil, context.DeadlineExceeded + if limit > cache.UnboundedListing && len(keys) > limit { + return keys[:limit], true, nil } - return keys, nil + return keys, false, nil } var _ cache.Catalog = memoryCatalog{} @@ -166,9 +166,69 @@ func TestPackedStoreTreatsMissingPackAsActionCacheMiss(t *testing.T) { backend.mu.Unlock() restore := testPackedServer(t, backend) defer closePackedServer(t, restore) + loadsAfterDiscovery := backend.loadCount() if response := readCacheObject(restore, "/ac/"+actionDigest); response.Code != http.StatusNotFound { t.Fatalf("missing pack action result = %d", response.Code) } + if backend.loadCount() != loadsAfterDiscovery { + t.Fatal("an evicted pack was downloaded even though the catalog listing omits it") + } + stats := restore.Snapshot() + if stats.PackLoadsSkipped != 1 || stats.BackendLoadErrors != 0 { + t.Fatalf("unexpected unavailable-pack stats: %+v", stats) + } +} + +func TestPackedStoreDiscoversPacksAndManifestsInOneListing(t *testing.T) { + backend := newMemoryBackend() + seed := testPackedServer(t, backend) + body := []byte("listed payload") + if response := putCacheObject(seed, "/cas/"+digest(body), body); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, seed) + + restore := testPackedServer(t, backend) + defer closePackedServer(t, restore) + stats := restore.Snapshot() + if stats.PacksDiscovered != 1 || stats.ManifestsDiscovered != 1 { + t.Fatalf("unexpected discovery stats: %+v", stats) + } + if response := readCacheObject(restore, "/cas/"+digest(body)); response.Code != http.StatusOK { + t.Fatalf("CAS GET = %d", response.Code) + } +} + +func TestPackedStoreLimitsDownloadedManifestsWithoutCountingPacks(t *testing.T) { + backend := newMemoryBackend() + payloads := [][]byte{[]byte("one"), []byte("two"), []byte("three")} + for _, body := range payloads { + writer := testPackedServer(t, backend) + if response := putCacheObject(writer, "/cas/"+digest(body), body); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, writer) + } + + restore := testServer(t, backend, func(cfg *Config) { + cfg.StorageMode = "packs" + cfg.Catalog = memoryCatalog{backend: backend} + cfg.PackSize = 1024 + cfg.PackFlushInterval = time.Hour + cfg.MaxManifests = 2 + }) + defer closePackedServer(t, restore) + stats := restore.Snapshot() + if stats.PacksDiscovered != 3 || stats.ManifestsDiscovered != 2 || !stats.ManifestDiscoveryTruncated { + t.Fatalf("unexpected bounded-discovery stats: %+v", stats) + } + for _, body := range payloads { + readCacheObject(restore, "/cas/"+digest(body)) + } + stats = restore.Snapshot() + if stats.Hits != 2 || stats.Misses != 1 { + t.Fatalf("max-manifests should bound manifest reads, not the pack listing: %+v", stats) + } } func TestPackedStoreRejectsConflictingActionResults(t *testing.T) { diff --git a/internal/server/server_test.go b/internal/server/server_test.go index 6ef1a16..a7fd7d9 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -26,6 +26,7 @@ type memoryBackend struct { existsErr error saveErr error saves int + loads int } type blockingSaveBackend struct { @@ -52,6 +53,7 @@ func newMemoryBackend() *memoryBackend { func (b *memoryBackend) Load(_ context.Context, key string, dst io.Writer) (bool, error) { b.mu.Lock() defer b.mu.Unlock() + b.loads++ if b.loadErr != nil { return false, b.loadErr } @@ -63,6 +65,12 @@ func (b *memoryBackend) Load(_ context.Context, key string, dst io.Writer) (bool return true, err } +func (b *memoryBackend) loadCount() int { + b.mu.Lock() + defer b.mu.Unlock() + return b.loads +} + func (b *memoryBackend) Exists(_ context.Context, key string) (bool, error) { b.mu.Lock() defer b.mu.Unlock() diff --git a/internal/server/stats.go b/internal/server/stats.go index b0637fc..6a7fc5b 100644 --- a/internal/server/stats.go +++ b/internal/server/stats.go @@ -28,7 +28,10 @@ type Stats struct { PackUploads uint64 `json:"pack_uploads"` ManifestUploads uint64 `json:"manifest_uploads"` PackDownloads uint64 `json:"pack_downloads"` + PackLoadsSkipped uint64 `json:"pack_loads_skipped"` + PacksDiscovered uint64 `json:"packs_discovered"` ManifestsDiscovered uint64 `json:"manifests_discovered"` + ManifestDiscoveryTruncated bool `json:"manifest_discovery_truncated"` ManifestDiscoveryErrors uint64 `json:"manifest_discovery_errors"` ManifestLoadErrors uint64 `json:"manifest_load_errors"` ActionDigestConflicts uint64 `json:"action_digest_conflicts"` @@ -56,7 +59,10 @@ type counters struct { packUploads atomic.Uint64 manifestUploads atomic.Uint64 packDownloads atomic.Uint64 + packLoadsSkipped atomic.Uint64 + packsDiscovered atomic.Uint64 manifestsDiscovered atomic.Uint64 + manifestDiscoveryTruncated atomic.Bool manifestDiscoveryErrors atomic.Uint64 manifestLoadErrors atomic.Uint64 actionDigestConflicts atomic.Uint64 @@ -85,7 +91,10 @@ func (c *counters) snapshot() Stats { PackUploads: c.packUploads.Load(), ManifestUploads: c.manifestUploads.Load(), PackDownloads: c.packDownloads.Load(), + PackLoadsSkipped: c.packLoadsSkipped.Load(), + PacksDiscovered: c.packsDiscovered.Load(), ManifestsDiscovered: c.manifestsDiscovered.Load(), + ManifestDiscoveryTruncated: c.manifestDiscoveryTruncated.Load(), ManifestDiscoveryErrors: c.manifestDiscoveryErrors.Load(), ManifestLoadErrors: c.manifestLoadErrors.Load(), ActionDigestConflicts: c.actionDigestConflicts.Load(), From 531fbf9a21c835ca9f12c4ed5d5231c580ab53c5 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 20 Sep 2026 14:50:02 +1000 Subject: [PATCH 02/55] Use GH native pagination for cache listing (#2) - Pagination traversal now uses `Link` header for continuation. - Manifests skipped due to limit are now precisely reported. --- action/post.js | 2 +- internal/cache/catalog.go | 123 ++++++++++++++++++++--------- internal/cache/catalog_test.go | 76 ++++++++++++------ internal/server/pack_store.go | 10 +-- internal/server/pack_store_test.go | 8 +- internal/server/stats.go | 6 +- 6 files changed, 153 insertions(+), 72 deletions(-) diff --git a/action/post.js b/action/post.js index 32d4d33..1b50a42 100644 --- a/action/post.js +++ b/action/post.js @@ -77,7 +77,7 @@ async function post() { `| Unavailable packs skipped | ${stats.pack_loads_skipped ?? 0} |`, `| Packs discovered | ${stats.packs_discovered ?? 0} |`, `| Manifests discovered | ${stats.manifests_discovered ?? 0} |`, - `| Manifest discovery truncated | ${stats.manifest_discovery_truncated ? "yes" : "no"} |`, + `| Manifests skipped | ${stats.manifests_skipped ?? 0} |`, `| Action-digest conflicts | ${stats.action_digest_conflicts ?? 0} |`, `| Read-only discarded uploads | ${stats.discarded_uploads ?? 0} |`, `| Backend downloads | ${stats.backend_downloads ?? 0} |`, diff --git a/internal/cache/catalog.go b/internal/cache/catalog.go index b03057e..7bc7ce6 100644 --- a/internal/cache/catalog.go +++ b/internal/cache/catalog.go @@ -9,7 +9,6 @@ import ( "net/http" "net/url" "os" - "strconv" "strings" "time" ) @@ -19,10 +18,10 @@ import ( // bytes are still restored through the runner cache-v2 service. Listing reads // metadata only, so it does not extend an entry's lifetime. type Catalog interface { - // List returns cache keys starting with keyPrefix, newest first. A positive - // limit stops the listing early and reports truncation; UnboundedListing - // returns every matching key. - List(ctx context.Context, keyPrefix string, limit int) (keys []string, truncated bool, err error) + // List returns cache keys starting with keyPrefix, newest first, and how + // many matching entries a positive limit left unlisted. UnboundedListing + // returns every matching key and always reports zero. + List(ctx context.Context, keyPrefix string, limit int) (keys []string, skipped int, err error) } // UnboundedListing lists every matching key. Use it only where a missing key @@ -70,54 +69,62 @@ func NewActionsCatalog(timeout time.Duration, logger *log.Logger) (*ActionsCatal } type actionsCacheListResponse struct { + TotalCount int `json:"total_count"` ActionsCaches []struct { Key string `json:"key"` } `json:"actions_caches"` } // List returns cache keys whose immutable key starts with keyPrefix, newest -// first, and reports whether a positive limit truncated the result. GitHub's -// API pagination is followed explicitly so a later writer does not silently -// hide older DAG parents. -func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) ([]string, bool, error) { - page := 1 +// first, and how many matching entries a positive limit left unlisted. +// Pagination follows the Link header rather than page sizes, so a short page +// cannot end the listing early and silently hide older DAG parents. +func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) ([]string, int, error) { + endpoint := *c.baseURL + endpoint.Path = strings.TrimRight(endpoint.Path, "/") + "/repos/" + c.repository + "/actions/caches" + query := endpoint.Query() + query.Set("key", keyPrefix) + // Newest first, so a truncated listing keeps the most recent entries + // instead of an arbitrary subset. + query.Set("sort", "created_at") + query.Set("direction", "desc") + query.Set("per_page", "100") + endpoint.RawQuery = query.Encode() + + next := endpoint.String() keys := make([]string, 0) unexpected := 0 - for { - endpoint := *c.baseURL - endpoint.Path = strings.TrimRight(endpoint.Path, "/") + "/repos/" + c.repository + "/actions/caches" - query := endpoint.Query() - query.Set("key", keyPrefix) - // Newest first, so a truncated listing keeps the most recent entries - // instead of an arbitrary subset. - query.Set("sort", "created_at") - query.Set("direction", "desc") - query.Set("per_page", "100") - query.Set("page", strconv.Itoa(page)) - endpoint.RawQuery = query.Encode() - - request, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil) + seen := 0 + for next != "" { + request, err := http.NewRequestWithContext(ctx, http.MethodGet, next, nil) if err != nil { - return nil, false, fmt.Errorf("create cache catalog request: %w", err) + return nil, 0, fmt.Errorf("create cache catalog request: %w", err) } request.Header.Set("Accept", "application/vnd.github+json") request.Header.Set("Authorization", "Bearer "+c.token) request.Header.Set("X-GitHub-Api-Version", "2022-11-28") response, err := c.client.Do(request) if err != nil { - return nil, false, fmt.Errorf("list GitHub Actions caches: %w", err) + return nil, 0, fmt.Errorf("list GitHub Actions caches: %w", err) } var result actionsCacheListResponse decodeErr := json.NewDecoder(response.Body).Decode(&result) + link := response.Header.Get("Link") _ = response.Body.Close() if response.StatusCode != http.StatusOK { - return nil, false, fmt.Errorf("list GitHub Actions caches: HTTP %d", response.StatusCode) + return nil, 0, fmt.Errorf("list GitHub Actions caches: HTTP %d", response.StatusCode) } if decodeErr != nil { - return nil, false, fmt.Errorf("decode GitHub Actions cache list: %w", decodeErr) + return nil, 0, fmt.Errorf("decode GitHub Actions cache list: %w", decodeErr) } for _, entry := range result.ActionsCaches { - if !strings.HasPrefix(entry.Key, keyPrefix) { + matches := strings.HasPrefix(entry.Key, keyPrefix) + if matches && limit > UnboundedListing && len(keys) == limit { + c.reportUnexpected(keyPrefix, unexpected) + return keys, unlistedFrom(result.TotalCount, seen), nil + } + seen++ + if !matches { // GitHub documents key as an explicit key or prefix, so a // non-matching entry means the filter no longer behaves as this // catalog assumes. @@ -127,18 +134,60 @@ func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) unexpected++ continue } - if limit > UnboundedListing && len(keys) == limit { - c.reportUnexpected(keyPrefix, unexpected) - return keys, true, nil - } keys = append(keys, entry.Key) } - if len(result.ActionsCaches) < 100 { - c.reportUnexpected(keyPrefix, unexpected) - return keys, false, nil + if next, err = c.nextPageURL(link); err != nil { + return nil, 0, err + } + } + c.reportUnexpected(keyPrefix, unexpected) + return keys, 0, nil +} + +// unlistedFrom counts what a limit left behind. total_count covers the whole +// query rather than one page, so it is a trustworthy remainder only while it +// exceeds the entries already consumed; otherwise only the entry that tripped +// the limit is known to be unlisted. +func unlistedFrom(totalCount, seen int) int { + if remaining := totalCount - seen; remaining > 0 { + return remaining + } + return 1 +} + +// nextPageURL returns the rel="next" target of a Link header, or an empty +// string on the final page. +func (c *ActionsCatalog) nextPageURL(header string) (string, error) { + for _, section := range strings.Split(header, ",") { + parts := strings.Split(strings.TrimSpace(section), ";") + if len(parts) < 2 { + continue + } + target := strings.TrimSpace(parts[0]) + if !strings.HasPrefix(target, "<") || !strings.HasSuffix(target, ">") { + continue + } + isNext := false + for _, parameter := range parts[1:] { + switch strings.TrimSpace(parameter) { + case `rel="next"`, "rel=next": + isNext = true + } + } + if !isNext { + continue + } + parsed, err := url.Parse(target[1 : len(target)-1]) + if err != nil { + return "", fmt.Errorf("parse cache listing pagination link: %w", err) + } + // Pagination must never leave the configured API host. + if parsed.Scheme != c.baseURL.Scheme || parsed.Host != c.baseURL.Host { + return "", fmt.Errorf("cache listing pagination link leaves %s", c.baseURL.Host) } - page++ + return parsed.String(), nil } + return "", nil } func (c *ActionsCatalog) reportUnexpected(keyPrefix string, unexpected int) { diff --git a/internal/cache/catalog_test.go b/internal/cache/catalog_test.go index f069f9a..72e7e09 100644 --- a/internal/cache/catalog_test.go +++ b/internal/cache/catalog_test.go @@ -11,27 +11,33 @@ import ( "testing" ) -func TestActionsCatalogListsAllPagesWithinPrefix(t *testing.T) { +func TestActionsCatalogFollowsShortPagesToTheFinalLink(t *testing.T) { requests := 0 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { requests++ if got := r.Header.Get("Authorization"); got != "Bearer token" { - t.Fatalf("authorization = %q", got) + t.Errorf("authorization = %q", got) } - if got := r.URL.Query().Get("key"); got != "prefix-manifest-" { - t.Fatalf("key = %q", got) + query := r.URL.Query() + if got := query.Get("key"); got != "prefix-manifest-" { + t.Errorf("key = %q", got) } - if got := r.URL.Query().Get("sort"); got != "created_at" { - t.Fatalf("sort = %q", got) + if got := query.Get("sort"); got != "created_at" { + t.Errorf("sort = %q", got) } - if got := r.URL.Query().Get("direction"); got != "desc" { - t.Fatalf("direction = %q", got) + if got := query.Get("direction"); got != "desc" { + t.Errorf("direction = %q", got) } - if r.URL.Query().Get("page") == "1" { - _, _ = w.Write([]byte(`{"actions_caches":[{"key":"prefix-manifest-one"}]}`)) + // A page far shorter than per_page must not end the listing while the + // server still advertises a next page. + if query.Get("page") != "2" { + query.Set("page", "2") + next := "http://" + r.Host + "/repos/owner/repository/actions/caches?" + query.Encode() + w.Header().Set("Link", `<`+next+`>; rel="next", <`+next+`>; rel="last"`) + _, _ = w.Write([]byte(`{"total_count":2,"actions_caches":[{"key":"prefix-manifest-one"}]}`)) return } - _, _ = w.Write([]byte(`{"actions_caches":[]}`)) + _, _ = w.Write([]byte(`{"total_count":2,"actions_caches":[{"key":"prefix-manifest-two"}]}`)) })) defer server.Close() baseURL, err := url.Parse(server.URL) @@ -39,18 +45,19 @@ func TestActionsCatalogListsAllPagesWithinPrefix(t *testing.T) { t.Fatal(err) } catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} - keys, truncated, err := catalog.List(context.Background(), "prefix-manifest-", 10) + keys, skipped, err := catalog.List(context.Background(), "prefix-manifest-", 10) if err != nil { t.Fatal(err) } - if strings.Join(keys, ",") != "prefix-manifest-one" || truncated || requests != 1 { - t.Fatalf("keys/truncated/requests = %v/%t/%d", keys, truncated, requests) + if strings.Join(keys, ",") != "prefix-manifest-one,prefix-manifest-two" || skipped != 0 || requests != 2 { + t.Fatalf("keys/skipped/requests = %v/%d/%d", keys, skipped, requests) } } -func TestActionsCatalogTruncatesAtLimitAndListsUnbounded(t *testing.T) { +func TestActionsCatalogRejectsPaginationLinkToAnotherHost(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - _, _ = w.Write([]byte(`{"actions_caches":[{"key":"prefix-one"},{"key":"prefix-two"}]}`)) + w.Header().Set("Link", `; rel="next"`) + _, _ = w.Write([]byte(`{"total_count":1,"actions_caches":[{"key":"prefix-one"}]}`)) })) defer server.Close() baseURL, err := url.Parse(server.URL) @@ -58,19 +65,44 @@ func TestActionsCatalogTruncatesAtLimitAndListsUnbounded(t *testing.T) { t.Fatal(err) } catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} - keys, truncated, err := catalog.List(context.Background(), "prefix-", 1) + if _, _, err := catalog.List(context.Background(), "prefix-", UnboundedListing); err == nil { + t.Fatal("pagination followed a link to another host") + } +} + +func TestActionsCatalogReportsUnlistedCountAtLimit(t *testing.T) { + totalCount := "5" + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(`{"total_count":` + totalCount + `,"actions_caches":[{"key":"prefix-one"},{"key":"prefix-two"}]}`)) + })) + defer server.Close() + baseURL, err := url.Parse(server.URL) if err != nil { t.Fatal(err) } - if strings.Join(keys, ",") != "prefix-one" || !truncated { - t.Fatalf("bounded keys/truncated = %v/%t", keys, truncated) + catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} + keys, skipped, err := catalog.List(context.Background(), "prefix-", 1) + if err != nil { + t.Fatal(err) + } + if strings.Join(keys, ",") != "prefix-one" || skipped != 4 { + t.Fatalf("bounded keys/skipped = %v/%d", keys, skipped) } - keys, truncated, err = catalog.List(context.Background(), "prefix-", UnboundedListing) + keys, skipped, err = catalog.List(context.Background(), "prefix-", UnboundedListing) if err != nil { t.Fatal(err) } - if strings.Join(keys, ",") != "prefix-one,prefix-two" || truncated { - t.Fatalf("unbounded keys/truncated = %v/%t", keys, truncated) + if strings.Join(keys, ",") != "prefix-one,prefix-two" || skipped != 0 { + t.Fatalf("unbounded keys/skipped = %v/%d", keys, skipped) + } + + // Without a usable total_count only the entry that tripped the limit is + // known to be unlisted, and the count must never collapse to zero. + totalCount = "0" + if _, skipped, err = catalog.List(context.Background(), "prefix-", 1); err != nil { + t.Fatal(err) + } else if skipped != 1 { + t.Fatalf("skipped without total_count = %d", skipped) } } diff --git a/internal/server/pack_store.go b/internal/server/pack_store.go index 2317bc9..f1d673a 100644 --- a/internal/server/pack_store.go +++ b/internal/server/pack_store.go @@ -669,16 +669,16 @@ func (p *packStore) discover(ctx context.Context) error { // entry's lifetime. Manifests are listed first, so the pack listing below // cannot miss a pack that a concurrent writer published before its // manifest. - manifestKeys, truncated, err := p.catalog.List(ctx, manifestKeyFor(p.keyPrefix, ""), p.maxManifests) + manifestKeys, skipped, err := p.catalog.List(ctx, manifestKeyFor(p.keyPrefix, ""), p.maxManifests) if err != nil { return err } p.server.stats.manifestsDiscovered.Add(uint64(len(manifestKeys))) - if truncated { - p.server.stats.manifestDiscoveryTruncated.Store(true) + if skipped > 0 { + p.server.stats.manifestsSkipped.Add(uint64(skipped)) p.server.cfg.Logger.Printf( - "manifest discovery stopped at the max-manifests limit of %d; older manifests are treated as cache misses", - p.maxManifests) + "manifest discovery stopped at the max-manifests limit of %d; %d older manifests are treated as cache misses", + p.maxManifests, skipped) } // Packs are only witnessed, never read, during discovery. A truncated pack // listing would look like eviction and suppress valid downloads, so it is diff --git a/internal/server/pack_store_test.go b/internal/server/pack_store_test.go index dfabcec..8896bad 100644 --- a/internal/server/pack_store_test.go +++ b/internal/server/pack_store_test.go @@ -16,7 +16,7 @@ type memoryCatalog struct { backend *memoryBackend } -func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]string, bool, error) { +func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]string, int, error) { c.backend.mu.Lock() defer c.backend.mu.Unlock() keys := make([]string, 0) @@ -27,9 +27,9 @@ func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]stri } sort.Strings(keys) if limit > cache.UnboundedListing && len(keys) > limit { - return keys[:limit], true, nil + return keys[:limit], len(keys) - limit, nil } - return keys, false, nil + return keys, 0, nil } var _ cache.Catalog = memoryCatalog{} @@ -219,7 +219,7 @@ func TestPackedStoreLimitsDownloadedManifestsWithoutCountingPacks(t *testing.T) }) defer closePackedServer(t, restore) stats := restore.Snapshot() - if stats.PacksDiscovered != 3 || stats.ManifestsDiscovered != 2 || !stats.ManifestDiscoveryTruncated { + if stats.PacksDiscovered != 3 || stats.ManifestsDiscovered != 2 || stats.ManifestsSkipped != 1 { t.Fatalf("unexpected bounded-discovery stats: %+v", stats) } for _, body := range payloads { diff --git a/internal/server/stats.go b/internal/server/stats.go index 6a7fc5b..ab560fb 100644 --- a/internal/server/stats.go +++ b/internal/server/stats.go @@ -31,7 +31,7 @@ type Stats struct { PackLoadsSkipped uint64 `json:"pack_loads_skipped"` PacksDiscovered uint64 `json:"packs_discovered"` ManifestsDiscovered uint64 `json:"manifests_discovered"` - ManifestDiscoveryTruncated bool `json:"manifest_discovery_truncated"` + ManifestsSkipped uint64 `json:"manifests_skipped"` ManifestDiscoveryErrors uint64 `json:"manifest_discovery_errors"` ManifestLoadErrors uint64 `json:"manifest_load_errors"` ActionDigestConflicts uint64 `json:"action_digest_conflicts"` @@ -62,7 +62,7 @@ type counters struct { packLoadsSkipped atomic.Uint64 packsDiscovered atomic.Uint64 manifestsDiscovered atomic.Uint64 - manifestDiscoveryTruncated atomic.Bool + manifestsSkipped atomic.Uint64 manifestDiscoveryErrors atomic.Uint64 manifestLoadErrors atomic.Uint64 actionDigestConflicts atomic.Uint64 @@ -94,7 +94,7 @@ func (c *counters) snapshot() Stats { PackLoadsSkipped: c.packLoadsSkipped.Load(), PacksDiscovered: c.packsDiscovered.Load(), ManifestsDiscovered: c.manifestsDiscovered.Load(), - ManifestDiscoveryTruncated: c.manifestDiscoveryTruncated.Load(), + ManifestsSkipped: c.manifestsSkipped.Load(), ManifestDiscoveryErrors: c.manifestDiscoveryErrors.Load(), ManifestLoadErrors: c.manifestLoadErrors.Load(), ActionDigestConflicts: c.actionDigestConflicts.Load(), From 778bdac8366b92eb2fc174b3b9353981852be6e6 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 20 Sep 2026 14:50:03 +1000 Subject: [PATCH 03/55] Skip reading of orphaned pack manifests (#4) - Manifests now include the hash of the pack they are for, so reads can be skipped if the associated pack is missing. This allows manifests to expire. - Ophaned manifests are reported in stats. --- README.md | 27 ++++-- action/post.js | 1 + docs/carv2-manifest-dag-concept.md | 19 +++- internal/cache/catalog.go | 58 ++++-------- internal/cache/catalog_test.go | 46 ++-------- internal/server/manifest.go | 11 ++- internal/server/pack_store.go | 94 ++++++++++++++------ internal/server/pack_store_test.go | 138 ++++++++++++++++++++++++++--- internal/server/stats.go | 3 + 9 files changed, 263 insertions(+), 134 deletions(-) diff --git a/README.md b/README.md index c2d638d..3600a8e 100644 --- a/README.md +++ b/README.md @@ -89,12 +89,27 @@ publish siblings without overwriting each other. Readers discover and merge all heads. If two manifests contain different Action Results for the same action digest, that digest is treated as a cache miss rather than picking one result. -Discovery makes two listings: a bounded one for manifests, honouring -`max-manifests` and newest first, and an unbounded one for packs. A manifest can -outlive the pack it references, because GitHub evicts entries independently. -When the pack listing shows that a pack is gone, its entries are resolved as -ordinary cache misses without attempting a download; `packs_discovered` and -`pack_loads_skipped` report that in the final statistics. +Each manifest key names the pack it commits: + +```text +-car-pack-v1- +-car-manifest-v2-- +``` + +Discovery lists both namespaces in full, newest first. Listing reads metadata +only, so it does not renew any entry's retention, and it is the download that is +worth limiting. Every mapping a manifest introduces lives in the pack its key +names, so a manifest missing from the pack listing is never downloaded. That +matters because reading a cache entry renews its retention: a small manifest +that is read on every run would otherwise outlive the large pack it describes +indefinitely, and GitHub would keep evicting packs instead. Unread manifests +simply expire. + +`max-manifests` is applied after that filter, so the budget is spent on +manifests that can still produce a cache hit rather than on orphans. +`manifests_orphaned`, `manifests_skipped`, and `pack_loads_skipped` report this +in the final statistics. + Manifest discovery is eventually consistent by design: an unseen manifest is only a temporary miss. diff --git a/action/post.js b/action/post.js index 1b50a42..ef27a3d 100644 --- a/action/post.js +++ b/action/post.js @@ -78,6 +78,7 @@ async function post() { `| Packs discovered | ${stats.packs_discovered ?? 0} |`, `| Manifests discovered | ${stats.manifests_discovered ?? 0} |`, `| Manifests skipped | ${stats.manifests_skipped ?? 0} |`, + `| Orphaned manifests | ${stats.manifests_orphaned ?? 0} |`, `| Action-digest conflicts | ${stats.action_digest_conflicts ?? 0} |`, `| Read-only discarded uploads | ${stats.discarded_uploads ?? 0} |`, `| Backend downloads | ${stats.backend_downloads ?? 0} |`, diff --git a/docs/carv2-manifest-dag-concept.md b/docs/carv2-manifest-dag-concept.md index 7944d15..2ea34f5 100644 --- a/docs/carv2-manifest-dag-concept.md +++ b/docs/carv2-manifest-dag-concept.md @@ -63,8 +63,17 @@ small CAS read into excessive transfer. ### Manifest A manifest is a small immutable DAG-CBOR block encoded with -`go-ipld-prime`. Its CID is the manifest identifier and its Actions-cache key -is derived from that CID. +`go-ipld-prime`. Its CID is the manifest identifier, and its Actions-cache key +pairs that CID with the single pack the manifest commits: +`-car-manifest-v2--`. + +The pairing is what makes the two entries share a fate. Every mapping a +manifest introduces lives in that one pack, so once the pack is gone the +manifest has nothing left to offer and a reader can tell that from the key +alone. This matters because a read renews an entry's retention: a manifest that +is downloaded on every run never ages out, while the much larger pack it +describes is evicted under the repository quota. Leaving orphaned manifests +unread lets them expire on the same schedule as the data they describe. The implemented DAG-CBOR schema has this logical content: @@ -136,7 +145,8 @@ merge. ## Read protocol and eviction -1. Bootstrap an in-memory manifest view from all discoverable heads. +1. Bootstrap an in-memory manifest view from all discoverable heads. Manifests + whose pack is absent from the pack listing are skipped without being read. 2. For `GET /ac/`, resolve the Action Result mapping, restore its pack, and validate every declared closure pack and referenced CAS digest. 3. For `GET /cas/`, resolve its pack, restore it on demand, look up the @@ -148,6 +158,9 @@ GitHub can evict any cache entry independently. The manifest must therefore not be treated as a promise that a pack still exists. This retains the v0.2 safety property that incomplete Action Results are never served. +A checkpoint manifest that commits several packs at once does not fit the +single-pack key, and needs its own key scheme before compaction can be added. + ## Rollout and validation The implementation should be a separate backend mode and namespace, initially diff --git a/internal/cache/catalog.go b/internal/cache/catalog.go index 7bc7ce6..9441123 100644 --- a/internal/cache/catalog.go +++ b/internal/cache/catalog.go @@ -18,17 +18,10 @@ import ( // bytes are still restored through the runner cache-v2 service. Listing reads // metadata only, so it does not extend an entry's lifetime. type Catalog interface { - // List returns cache keys starting with keyPrefix, newest first, and how - // many matching entries a positive limit left unlisted. UnboundedListing - // returns every matching key and always reports zero. - List(ctx context.Context, keyPrefix string, limit int) (keys []string, skipped int, err error) + // List returns every cache key starting with keyPrefix, newest first. + List(ctx context.Context, keyPrefix string) ([]string, error) } -// UnboundedListing lists every matching key. Use it only where a missing key -// changes a decision, because a truncated listing would silently look like -// absence. -const UnboundedListing = 0 - // ActionsCatalog lists cache metadata through the public GitHub REST API. // A normal GITHUB_TOKEN with actions: read is sufficient. It deliberately // does not expose deletion or mutation operations. @@ -69,23 +62,22 @@ func NewActionsCatalog(timeout time.Duration, logger *log.Logger) (*ActionsCatal } type actionsCacheListResponse struct { - TotalCount int `json:"total_count"` ActionsCaches []struct { Key string `json:"key"` } `json:"actions_caches"` } -// List returns cache keys whose immutable key starts with keyPrefix, newest -// first, and how many matching entries a positive limit left unlisted. -// Pagination follows the Link header rather than page sizes, so a short page -// cannot end the listing early and silently hide older DAG parents. -func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) ([]string, int, error) { +// List returns every cache key whose immutable key starts with keyPrefix, +// newest first. Pagination follows the Link header rather than page sizes, so +// a short page cannot end the listing early and silently hide older DAG +// parents. +func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string) ([]string, error) { endpoint := *c.baseURL endpoint.Path = strings.TrimRight(endpoint.Path, "/") + "/repos/" + c.repository + "/actions/caches" query := endpoint.Query() query.Set("key", keyPrefix) - // Newest first, so a truncated listing keeps the most recent entries - // instead of an arbitrary subset. + // Newest first, so a caller that reads only part of the listing keeps the + // most recent entries rather than an arbitrary subset. query.Set("sort", "created_at") query.Set("direction", "desc") query.Set("per_page", "100") @@ -94,37 +86,30 @@ func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) next := endpoint.String() keys := make([]string, 0) unexpected := 0 - seen := 0 for next != "" { request, err := http.NewRequestWithContext(ctx, http.MethodGet, next, nil) if err != nil { - return nil, 0, fmt.Errorf("create cache catalog request: %w", err) + return nil, fmt.Errorf("create cache catalog request: %w", err) } request.Header.Set("Accept", "application/vnd.github+json") request.Header.Set("Authorization", "Bearer "+c.token) request.Header.Set("X-GitHub-Api-Version", "2022-11-28") response, err := c.client.Do(request) if err != nil { - return nil, 0, fmt.Errorf("list GitHub Actions caches: %w", err) + return nil, fmt.Errorf("list GitHub Actions caches: %w", err) } var result actionsCacheListResponse decodeErr := json.NewDecoder(response.Body).Decode(&result) link := response.Header.Get("Link") _ = response.Body.Close() if response.StatusCode != http.StatusOK { - return nil, 0, fmt.Errorf("list GitHub Actions caches: HTTP %d", response.StatusCode) + return nil, fmt.Errorf("list GitHub Actions caches: HTTP %d", response.StatusCode) } if decodeErr != nil { - return nil, 0, fmt.Errorf("decode GitHub Actions cache list: %w", decodeErr) + return nil, fmt.Errorf("decode GitHub Actions cache list: %w", decodeErr) } for _, entry := range result.ActionsCaches { - matches := strings.HasPrefix(entry.Key, keyPrefix) - if matches && limit > UnboundedListing && len(keys) == limit { - c.reportUnexpected(keyPrefix, unexpected) - return keys, unlistedFrom(result.TotalCount, seen), nil - } - seen++ - if !matches { + if !strings.HasPrefix(entry.Key, keyPrefix) { // GitHub documents key as an explicit key or prefix, so a // non-matching entry means the filter no longer behaves as this // catalog assumes. @@ -137,22 +122,11 @@ func (c *ActionsCatalog) List(ctx context.Context, keyPrefix string, limit int) keys = append(keys, entry.Key) } if next, err = c.nextPageURL(link); err != nil { - return nil, 0, err + return nil, err } } c.reportUnexpected(keyPrefix, unexpected) - return keys, 0, nil -} - -// unlistedFrom counts what a limit left behind. total_count covers the whole -// query rather than one page, so it is a trustworthy remainder only while it -// exceeds the entries already consumed; otherwise only the entry that tripped -// the limit is known to be unlisted. -func unlistedFrom(totalCount, seen int) int { - if remaining := totalCount - seen; remaining > 0 { - return remaining - } - return 1 + return keys, nil } // nextPageURL returns the rel="next" target of a Link header, or an empty diff --git a/internal/cache/catalog_test.go b/internal/cache/catalog_test.go index 72e7e09..7bde7dd 100644 --- a/internal/cache/catalog_test.go +++ b/internal/cache/catalog_test.go @@ -45,12 +45,12 @@ func TestActionsCatalogFollowsShortPagesToTheFinalLink(t *testing.T) { t.Fatal(err) } catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} - keys, skipped, err := catalog.List(context.Background(), "prefix-manifest-", 10) + keys, err := catalog.List(context.Background(), "prefix-manifest-") if err != nil { t.Fatal(err) } - if strings.Join(keys, ",") != "prefix-manifest-one,prefix-manifest-two" || skipped != 0 || requests != 2 { - t.Fatalf("keys/skipped/requests = %v/%d/%d", keys, skipped, requests) + if strings.Join(keys, ",") != "prefix-manifest-one,prefix-manifest-two" || requests != 2 { + t.Fatalf("keys/requests = %v/%d", keys, requests) } } @@ -65,47 +65,11 @@ func TestActionsCatalogRejectsPaginationLinkToAnotherHost(t *testing.T) { t.Fatal(err) } catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} - if _, _, err := catalog.List(context.Background(), "prefix-", UnboundedListing); err == nil { + if _, err := catalog.List(context.Background(), "prefix-"); err == nil { t.Fatal("pagination followed a link to another host") } } -func TestActionsCatalogReportsUnlistedCountAtLimit(t *testing.T) { - totalCount := "5" - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - _, _ = w.Write([]byte(`{"total_count":` + totalCount + `,"actions_caches":[{"key":"prefix-one"},{"key":"prefix-two"}]}`)) - })) - defer server.Close() - baseURL, err := url.Parse(server.URL) - if err != nil { - t.Fatal(err) - } - catalog := &ActionsCatalog{baseURL: baseURL, repository: "owner/repository", token: "token", client: server.Client()} - keys, skipped, err := catalog.List(context.Background(), "prefix-", 1) - if err != nil { - t.Fatal(err) - } - if strings.Join(keys, ",") != "prefix-one" || skipped != 4 { - t.Fatalf("bounded keys/skipped = %v/%d", keys, skipped) - } - keys, skipped, err = catalog.List(context.Background(), "prefix-", UnboundedListing) - if err != nil { - t.Fatal(err) - } - if strings.Join(keys, ",") != "prefix-one,prefix-two" || skipped != 0 { - t.Fatalf("unbounded keys/skipped = %v/%d", keys, skipped) - } - - // Without a usable total_count only the entry that tripped the limit is - // known to be unlisted, and the count must never collapse to zero. - totalCount = "0" - if _, skipped, err = catalog.List(context.Background(), "prefix-", 1); err != nil { - t.Fatal(err) - } else if skipped != 1 { - t.Fatalf("skipped without total_count = %d", skipped) - } -} - func TestActionsCatalogLogsKeysOutsideTheRequestedPrefix(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"actions_caches":[{"key":"prefix-one"},{"key":"unrelated"},{"key":"another"}]}`)) @@ -123,7 +87,7 @@ func TestActionsCatalogLogsKeysOutsideTheRequestedPrefix(t *testing.T) { client: server.Client(), logger: log.New(&logged, "", 0), } - keys, _, err := catalog.List(context.Background(), "prefix-", UnboundedListing) + keys, err := catalog.List(context.Background(), "prefix-") if err != nil { t.Fatal(err) } diff --git a/internal/server/manifest.go b/internal/server/manifest.go index 147d2f0..3a29ccd 100644 --- a/internal/server/manifest.go +++ b/internal/server/manifest.go @@ -524,8 +524,15 @@ func packKeyFor(prefix, id string) string { return carKeyPrefix(prefix) + "pack-v1-" + id } -func manifestKeyFor(prefix, id string) string { - return carKeyPrefix(prefix) + "manifest-v1-" + id +func manifestKeyPrefix(prefix string) string { + return carKeyPrefix(prefix) + "manifest-v2-" +} + +// manifestKeyFor names a manifest after the pack it commits, so a reader can +// tell from a listing alone that a manifest has outlived its pack and is not +// worth downloading. +func manifestKeyFor(prefix, packID, manifestID string) string { + return manifestKeyPrefix(prefix) + packID + "-" + manifestID } func stringsHasSuffix(value, suffix string) bool { diff --git a/internal/server/pack_store.go b/internal/server/pack_store.go index f1d673a..ea33f9e 100644 --- a/internal/server/pack_store.go +++ b/internal/server/pack_store.go @@ -446,7 +446,7 @@ func (p *packStore) flushOneLocked(ctx context.Context) (bool, error) { if err != nil { return false, err } - if err := p.publishFile(ctx, manifestKeyFor(p.keyPrefix, manifestID), manifestPath, int64(len(manifestData))); err != nil { + if err := p.publishFile(ctx, manifestKeyFor(p.keyPrefix, pack.ID, manifestID), manifestPath, int64(len(manifestData))); err != nil { return false, fmt.Errorf("publish manifest commit point: %w", err) } p.server.stats.manifestUploads.Add(1) @@ -664,26 +664,27 @@ func filterPending[T any](order []string, values map[string]T) []string { return filtered } +// manifestReference is a listed manifest that is still worth downloading. +type manifestReference struct { + key string + packID string + id string +} + func (p *packStore) discover(ctx context.Context) error { // Listing reads metadata only: unlike a download it does not extend an - // entry's lifetime. Manifests are listed first, so the pack listing below - // cannot miss a pack that a concurrent writer published before its - // manifest. - manifestKeys, skipped, err := p.catalog.List(ctx, manifestKeyFor(p.keyPrefix, ""), p.maxManifests) + // entry's lifetime, so both listings are unbounded and max-manifests is + // spent on downloads instead. Manifests are listed first, so the pack + // listing below cannot miss a pack that a concurrent writer published + // before its manifest. + manifestKeys, err := p.catalog.List(ctx, manifestKeyPrefix(p.keyPrefix)) if err != nil { return err } p.server.stats.manifestsDiscovered.Add(uint64(len(manifestKeys))) - if skipped > 0 { - p.server.stats.manifestsSkipped.Add(uint64(skipped)) - p.server.cfg.Logger.Printf( - "manifest discovery stopped at the max-manifests limit of %d; %d older manifests are treated as cache misses", - p.maxManifests, skipped) - } - // Packs are only witnessed, never read, during discovery. A truncated pack - // listing would look like eviction and suppress valid downloads, so it is - // bounded by the repository rather than by max-manifests. - packKeys, _, err := p.catalog.List(ctx, packKeyFor(p.keyPrefix, ""), cache.UnboundedListing) + // A truncated pack listing would look like eviction and suppress valid + // downloads, so this one must be complete. + packKeys, err := p.catalog.List(ctx, packKeyFor(p.keyPrefix, "")) if err != nil { return err } @@ -694,20 +695,53 @@ func (p *packStore) discover(ctx context.Context) error { } p.packsListed = true p.server.stats.packsDiscovered.Add(uint64(len(p.listedPacks))) - manifests := make(map[string]manifest, len(manifestKeys)) - parents := make(map[string]struct{}) + + live := make([]manifestReference, 0, len(manifestKeys)) + orphaned := 0 for _, key := range manifestKeys { - manifestID, ok := parseManifestKey(p.keyPrefix, key) + packID, manifestID, ok := parseManifestKey(p.keyPrefix, key) if !ok { continue } - value, err := p.loadManifest(ctx, key, manifestID) + // Every mapping a manifest introduces lives in the pack named by its + // key, so an orphaned manifest has nothing left to offer. Leaving it + // unread is what lets it expire instead of being renewed forever. + if _, listed := p.listedPacks[packID]; !listed { + orphaned++ + continue + } + live = append(live, manifestReference{key: key, packID: packID, id: manifestID}) + } + if orphaned > 0 { + p.server.stats.manifestsOrphaned.Add(uint64(orphaned)) + p.server.cfg.Logger.Printf("skipped %d manifests whose packs are gone; unread manifests expire on their own", orphaned) + } + // Applying the limit after the orphan filter keeps the budget on manifests + // that can still contribute cache hits. + if len(live) > p.maxManifests { + skipped := len(live) - p.maxManifests + p.server.stats.manifestsSkipped.Add(uint64(skipped)) + p.server.cfg.Logger.Printf( + "%d live manifests exceed the max-manifests limit of %d; the %d oldest are treated as cache misses", + len(live), p.maxManifests, skipped) + live = live[:p.maxManifests] + } + + manifests := make(map[string]manifest, len(live)) + parents := make(map[string]struct{}) + for _, reference := range live { + value, err := p.loadManifest(ctx, reference.key, reference.id) if err != nil { p.server.stats.manifestLoadErrors.Add(1) - p.server.cfg.Logger.Printf("ignoring unavailable manifest %s: %s", manifestID, safeError(err)) + p.server.cfg.Logger.Printf("ignoring unavailable manifest %s: %s", reference.id, safeError(err)) continue } - manifests[manifestID] = value + if len(value.Packs) != 1 || value.Packs[0].ID != reference.packID { + p.server.stats.manifestLoadErrors.Add(1) + p.server.cfg.Logger.Printf("ignoring manifest %s: it does not commit the pack %s named by its key", reference.id, reference.packID) + continue + } + manifests[reference.id] = value for _, parent := range value.Parents { parents[parent] = struct{}{} } @@ -774,13 +808,21 @@ func (p *packStore) applyManifestLocked(id string, value manifest) { p.heads[id] = struct{}{} } -func parseManifestKey(prefix, key string) (string, bool) { - head := manifestKeyFor(prefix, "") +func parseManifestKey(prefix, key string) (string, string, bool) { + head := manifestKeyPrefix(prefix) if len(key) <= len(head) || key[:len(head)] != head { - return "", false + return "", "", false } - id := key[len(head):] - return id, validCID(id) + rest := key[len(head):] + const packIDLength = 64 + if len(rest) <= packIDLength+1 || rest[packIDLength] != '-' { + return "", "", false + } + packID, manifestID := rest[:packIDLength], rest[packIDLength+1:] + if !digestPattern.MatchString(packID) || !validCID(manifestID) { + return "", "", false + } + return packID, manifestID, true } func parsePackKey(prefix, key string) (string, bool) { diff --git a/internal/server/pack_store_test.go b/internal/server/pack_store_test.go index 8896bad..60230da 100644 --- a/internal/server/pack_store_test.go +++ b/internal/server/pack_store_test.go @@ -16,7 +16,7 @@ type memoryCatalog struct { backend *memoryBackend } -func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]string, int, error) { +func (c memoryCatalog) List(_ context.Context, prefix string) ([]string, error) { c.backend.mu.Lock() defer c.backend.mu.Unlock() keys := make([]string, 0) @@ -26,14 +26,31 @@ func (c memoryCatalog) List(_ context.Context, prefix string, limit int) ([]stri } } sort.Strings(keys) - if limit > cache.UnboundedListing && len(keys) > limit { - return keys[:limit], len(keys) - limit, nil - } - return keys, 0, nil + return keys, nil } var _ cache.Catalog = memoryCatalog{} +// phantomCatalog reports keys the backend cannot serve, as GitHub's REST +// listing does for packs outside the running job's cache scope. +type phantomCatalog struct { + memoryCatalog + phantom []string +} + +func (c phantomCatalog) List(ctx context.Context, prefix string) ([]string, error) { + keys, err := c.memoryCatalog.List(ctx, prefix) + if err != nil { + return nil, err + } + for _, key := range c.phantom { + if strings.HasPrefix(key, prefix) { + keys = append(keys, key) + } + } + return keys, nil +} + func testPackedServer(t *testing.T, backend *memoryBackend) *Server { return testPackedServerWithMaxBlob(t, backend, 1024) } @@ -148,7 +165,7 @@ func TestPackedStoreMergesConcurrentManifestHeads(t *testing.T) { } } -func TestPackedStoreTreatsMissingPackAsActionCacheMiss(t *testing.T) { +func TestPackedStoreLeavesOrphanedManifestsUnread(t *testing.T) { backend := newMemoryBackend() seed := testPackedServer(t, backend) actionDigest := digest([]byte("action")) @@ -157,6 +174,7 @@ func TestPackedStoreTreatsMissingPackAsActionCacheMiss(t *testing.T) { } closePackedServer(t, seed) + // Emulate GitHub evicting the large pack while its small manifest survives. backend.mu.Lock() for key := range backend.objects { if strings.Contains(key, "-car-pack-v1-") { @@ -164,22 +182,66 @@ func TestPackedStoreTreatsMissingPackAsActionCacheMiss(t *testing.T) { } } backend.mu.Unlock() + + loadsBeforeDiscovery := backend.loadCount() restore := testPackedServer(t, backend) defer closePackedServer(t, restore) - loadsAfterDiscovery := backend.loadCount() + if backend.loadCount() != loadsBeforeDiscovery { + t.Fatal("an orphaned manifest was downloaded, which would renew its lifetime") + } if response := readCacheObject(restore, "/ac/"+actionDigest); response.Code != http.StatusNotFound { - t.Fatalf("missing pack action result = %d", response.Code) + t.Fatalf("orphaned action result = %d", response.Code) + } + stats := restore.Snapshot() + if stats.ManifestsDiscovered != 1 || stats.ManifestsOrphaned != 1 || stats.BackendLoadErrors != 0 { + t.Fatalf("unexpected orphaned-manifest stats: %+v", stats) } - if backend.loadCount() != loadsAfterDiscovery { - t.Fatal("an evicted pack was downloaded even though the catalog listing omits it") +} + +func TestPackedStoreRetriesAnUnrestorablePackOnlyOnce(t *testing.T) { + backend := newMemoryBackend() + seed := testPackedServer(t, backend) + body := []byte("out of scope payload") + if response := putCacheObject(seed, "/cas/"+digest(body), body); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, seed) + + // A pack listed for the repository can still be outside this job's cache + // scope, which only a failed download reveals. + var packKey string + backend.mu.Lock() + for key := range backend.objects { + if strings.Contains(key, "-car-pack-v1-") { + packKey = key + } + } + delete(backend.objects, packKey) + backend.mu.Unlock() + if packKey == "" { + t.Fatal("no pack was published") + } + + restore := testServer(t, backend, func(cfg *Config) { + cfg.StorageMode = "packs" + cfg.Catalog = phantomCatalog{memoryCatalog{backend: backend}, []string{packKey}} + cfg.PackSize = 1024 + cfg.PackFlushInterval = time.Hour + cfg.MaxManifests = 100 + }) + defer closePackedServer(t, restore) + for attempt := 0; attempt < 2; attempt++ { + if response := readCacheObject(restore, "/cas/"+digest(body)); response.Code != http.StatusNotFound { + t.Fatalf("attempt %d = %d", attempt, response.Code) + } } stats := restore.Snapshot() - if stats.PackLoadsSkipped != 1 || stats.BackendLoadErrors != 0 { - t.Fatalf("unexpected unavailable-pack stats: %+v", stats) + if stats.ManifestsOrphaned != 0 || stats.PackLoadsSkipped != 1 { + t.Fatalf("an unrestorable pack was not memoized: %+v", stats) } } -func TestPackedStoreDiscoversPacksAndManifestsInOneListing(t *testing.T) { +func TestPackedStoreDiscoversPacksAndManifests(t *testing.T) { backend := newMemoryBackend() seed := testPackedServer(t, backend) body := []byte("listed payload") @@ -219,7 +281,7 @@ func TestPackedStoreLimitsDownloadedManifestsWithoutCountingPacks(t *testing.T) }) defer closePackedServer(t, restore) stats := restore.Snapshot() - if stats.PacksDiscovered != 3 || stats.ManifestsDiscovered != 2 || stats.ManifestsSkipped != 1 { + if stats.PacksDiscovered != 3 || stats.ManifestsDiscovered != 3 || stats.ManifestsSkipped != 1 { t.Fatalf("unexpected bounded-discovery stats: %+v", stats) } for _, body := range payloads { @@ -231,6 +293,54 @@ func TestPackedStoreLimitsDownloadedManifestsWithoutCountingPacks(t *testing.T) } } +func TestPackedStoreDoesNotSpendTheManifestLimitOnOrphans(t *testing.T) { + backend := newMemoryBackend() + payloads := [][]byte{[]byte("one"), []byte("two"), []byte("three")} + packKeys := make(map[string]string, len(payloads)) + known := make(map[string]bool) + for _, body := range payloads { + writer := testPackedServer(t, backend) + if response := putCacheObject(writer, "/cas/"+digest(body), body); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, writer) + backend.mu.Lock() + for key := range backend.objects { + if strings.Contains(key, "-car-pack-v1-") && !known[key] { + known[key] = true + packKeys[string(body)] = key + } + } + backend.mu.Unlock() + } + + // Two of the three manifests are orphaned. A budget of one must be spent on + // the manifest that can still produce a hit. + backend.mu.Lock() + delete(backend.objects, packKeys["one"]) + delete(backend.objects, packKeys["two"]) + backend.mu.Unlock() + + restore := testServer(t, backend, func(cfg *Config) { + cfg.StorageMode = "packs" + cfg.Catalog = memoryCatalog{backend: backend} + cfg.PackSize = 1024 + cfg.PackFlushInterval = time.Hour + cfg.MaxManifests = 1 + }) + defer closePackedServer(t, restore) + stats := restore.Snapshot() + if stats.ManifestsDiscovered != 3 || stats.ManifestsOrphaned != 2 || stats.ManifestsSkipped != 0 { + t.Fatalf("orphans consumed the manifest budget: %+v", stats) + } + if response := readCacheObject(restore, "/cas/"+digest([]byte("three"))); response.Code != http.StatusOK { + t.Fatalf("live manifest was not read: %d", response.Code) + } + if response := readCacheObject(restore, "/cas/"+digest([]byte("one"))); response.Code != http.StatusNotFound { + t.Fatalf("orphaned mapping = %d", response.Code) + } +} + func TestPackedStoreRejectsConflictingActionResults(t *testing.T) { backend := newMemoryBackend() writerA := testPackedServer(t, backend) diff --git a/internal/server/stats.go b/internal/server/stats.go index ab560fb..652d8ce 100644 --- a/internal/server/stats.go +++ b/internal/server/stats.go @@ -32,6 +32,7 @@ type Stats struct { PacksDiscovered uint64 `json:"packs_discovered"` ManifestsDiscovered uint64 `json:"manifests_discovered"` ManifestsSkipped uint64 `json:"manifests_skipped"` + ManifestsOrphaned uint64 `json:"manifests_orphaned"` ManifestDiscoveryErrors uint64 `json:"manifest_discovery_errors"` ManifestLoadErrors uint64 `json:"manifest_load_errors"` ActionDigestConflicts uint64 `json:"action_digest_conflicts"` @@ -63,6 +64,7 @@ type counters struct { packsDiscovered atomic.Uint64 manifestsDiscovered atomic.Uint64 manifestsSkipped atomic.Uint64 + manifestsOrphaned atomic.Uint64 manifestDiscoveryErrors atomic.Uint64 manifestLoadErrors atomic.Uint64 actionDigestConflicts atomic.Uint64 @@ -95,6 +97,7 @@ func (c *counters) snapshot() Stats { PacksDiscovered: c.packsDiscovered.Load(), ManifestsDiscovered: c.manifestsDiscovered.Load(), ManifestsSkipped: c.manifestsSkipped.Load(), + ManifestsOrphaned: c.manifestsOrphaned.Load(), ManifestDiscoveryErrors: c.manifestDiscoveryErrors.Load(), ManifestLoadErrors: c.manifestLoadErrors.Load(), ActionDigestConflicts: c.actionDigestConflicts.Load(), From c292f47cb8f6f47a9ac4a3d6ff0bb875efbc418f Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 20 Sep 2026 14:50:03 +1000 Subject: [PATCH 04/55] Presence checks do not trigger pack downloads (#5) * Presence checks do not trigger pack downloads - Presence checks for blobs no longer trigger an eager download of packs. - To ensure packs containing blobs prescence checks included are not discarded, renewal is scheduled (skipped if downloaded before a timeout). Configurable with `--pack-renew-interval`. - Pack renewals are reported in stats. * Expose pack renewal duration in action interface --- README.md | 28 +++- action.yml | 4 + action/main.js | 3 + action/post.js | 1 + cmd/cache-server/main.go | 2 + docs/carv2-manifest-dag-concept.md | 8 +- internal/server/action_result_test.go | 7 + internal/server/action_result_validation.go | 23 +++- internal/server/pack_store.go | 132 +++++++++++++++++- internal/server/pack_store_test.go | 144 ++++++++++++++++++++ internal/server/server.go | 53 ++++++- internal/server/server_test.go | 22 ++- internal/server/stats.go | 3 + 13 files changed, 404 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 3600a8e..ba7d43a 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,28 @@ in the final statistics. Manifest discovery is eventually consistent by design: an unseen manifest is only a temporary miss. +A `HEAD /cas/` is answered from the manifest view without restoring the +pack, so `--remote_download_minimal` builds do not pull archives they never +read. Because reading an entry is what resets its retention, a pack that only +ever answers presence checks would then be evicted while Bazel still depends on +it. The server therefore renews it explicitly: once per pack per job, batched +for `pack-renew-seconds` so a pack that gets downloaded in the meantime costs no +extra API call, and flushed at shutdown. A renewal resolves cache metadata +without transferring the pack, and is reported as `pack_renewals`. + +Action results use the same presence check. `GET /ac/` restores only the +pack holding the result itself, then confirms every referenced blob is mapped to +a pack that still exists and that its recorded size matches the action result. +An action result is a cache miss whenever any output is unmapped, or lives in a +pack that eviction has removed. Serving it renews the retention of every pack in +its closure, so a result that Bazel keeps hitting keeps its outputs alive even +when they are never downloaded. + +The tradeoff is deliberate: availability is judged from the manifest view and +the pack listing rather than by restoring every output. A pack that disappears +between discovery and a later fetch yields a miss on that fetch instead of +suppressing the action result up front. + The server flushes a pending pack when it reaches `pack-size-mb`, at least once per `pack-flush-seconds`, and unconditionally during the action post step. It uploads the CARv2 file first and the manifest second; the manifest is the @@ -153,6 +175,7 @@ Do not enable Bazel remote-cache compression with this release. | `storage-mode` | `objects` | `objects` (v0.2) or `packs` (CARv2 and manifest DAG) | | `pack-size-mb` | `8` | Target size for a CARv2 archive; only for `packs`, 1–32 MiB | | `pack-flush-seconds` | `30` | Maximum local staging interval; only for `packs` | +| `pack-renew-seconds` | `15` | Batching delay for pack retention renewals; only for `packs` | | `max-manifests` | `2048` | Maximum manifests downloaded during discovery; only for `packs` | | `github-token` | `${{ github.token }}` | `actions: read` token for packed-manifest discovery | | `max-blob-size-mb` | `512` | Maximum spooled upload/download size | @@ -212,8 +235,9 @@ correctness. Because GitHub evicts entries independently, an AC entry can outlive one of its referenced CAS entries. The adapter checks the complete output closure before serving or publishing an action result and degrades an incomplete closure to an -ordinary cache miss. In packed mode this restores and verifies each referenced -CARv2 pack and CAS block before serving the Action Result. One action result is +ordinary cache miss. In packed mode that check resolves each referenced blob +through the manifest view and the pack listing, without restoring the packs, and +renews their retention. One action result is limited to 100,000 distinct validation operations to bound amplification from a malformed cache entry. diff --git a/action.yml b/action.yml index 0042b73..c5f02b8 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,10 @@ inputs: description: "Maximum seconds that staged CARv2 objects wait before publication" required: false default: "30" + pack-renew-seconds: + description: "Seconds that pack retention renewals are batched before being sent; renewals also flush at shutdown" + required: false + default: "15" max-manifests: description: "Maximum manifests to download during discovery; any beyond this are ignored and become cache misses" required: false diff --git a/action/main.js b/action/main.js index 5740db4..a361211 100644 --- a/action/main.js +++ b/action/main.js @@ -67,6 +67,7 @@ async function main() { } const packSizeMB = positiveInteger("pack-size-mb", 8, 32); const packFlushSeconds = positiveInteger("pack-flush-seconds", 30, 3600); + const packRenewSeconds = positiveInteger("pack-renew-seconds", 15, 3600); const maxManifests = positiveInteger("max-manifests", 2048, 10_000); const githubToken = input("github-token", ""); if (storageMode === "packs" && !githubToken) { @@ -102,6 +103,8 @@ async function main() { String(packSizeMB * 1024 * 1024), "--pack-flush-interval", `${packFlushSeconds}s`, + "--pack-renew-interval", + `${packRenewSeconds}s`, "--max-manifests", String(maxManifests), booleanFlag("write-enabled", writeEnabled), diff --git a/action/post.js b/action/post.js index ef27a3d..312a9b1 100644 --- a/action/post.js +++ b/action/post.js @@ -74,6 +74,7 @@ async function post() { `| CARv2 pack uploads | ${stats.pack_uploads ?? 0} |`, `| Manifest uploads | ${stats.manifest_uploads ?? 0} |`, `| CARv2 pack downloads | ${stats.pack_downloads ?? 0} |`, + `| Pack retention renewals | ${stats.pack_renewals ?? 0} |`, `| Unavailable packs skipped | ${stats.pack_loads_skipped ?? 0} |`, `| Packs discovered | ${stats.packs_discovered ?? 0} |`, `| Manifests discovered | ${stats.manifests_discovered ?? 0} |`, diff --git a/cmd/cache-server/main.go b/cmd/cache-server/main.go index 8b7bfa3..6196954 100644 --- a/cmd/cache-server/main.go +++ b/cmd/cache-server/main.go @@ -43,6 +43,7 @@ func run() error { storageMode = flag.String("storage-mode", "objects", "storage mode: objects or packs") packSize = flag.Int64("pack-size", 8*1024*1024, "target CARv2 pack size in bytes") packFlush = flag.Duration("pack-flush-interval", 30*time.Second, "maximum delay before flushing pending CARv2 data") + packRenew = flag.Duration("pack-renew-interval", 15*time.Second, "delay before renewing retention for packs that only presence checks touched") maxManifests = flag.Int("max-manifests", 2048, "maximum manifests to read during discovery; any beyond this are ignored") writeEnabled = flag.Bool("write-enabled", false, "publish validated uploads") failOpen = flag.Bool("fail-open", true, "degrade backend errors to misses/success") @@ -104,6 +105,7 @@ func run() error { StorageMode: *storageMode, PackSize: *packSize, PackFlushInterval: *packFlush, + PackRenewInterval: *packRenew, MaxManifests: *maxManifests, WriteEnabled: *writeEnabled, FailOpen: *failOpen, diff --git a/docs/carv2-manifest-dag-concept.md b/docs/carv2-manifest-dag-concept.md index 2ea34f5..313bb2b 100644 --- a/docs/carv2-manifest-dag-concept.md +++ b/docs/carv2-manifest-dag-concept.md @@ -147,12 +147,16 @@ merge. 1. Bootstrap an in-memory manifest view from all discoverable heads. Manifests whose pack is absent from the pack listing are skipped without being read. -2. For `GET /ac/`, resolve the Action Result mapping, restore its - pack, and validate every declared closure pack and referenced CAS digest. +2. For `GET /ac/`, resolve the Action Result mapping and restore + its pack, then confirm every declared closure member is mapped to a pack + that still exists and has the declared size. Closure packs are not restored; + their retention is renewed instead. 3. For `GET /cas/`, resolve its pack, restore it on demand, look up the CID in the CARv2 index, and verify digest and size before responding. 4. If a manifest, pack, or closure member is missing or fails verification, return a cache miss. +5. A CAS presence check resolves from the manifest view without restoring the + pack, and schedules one deferred retention renewal for it. GitHub can evict any cache entry independently. The manifest must therefore not be treated as a promise that a pack still exists. This retains the v0.2 safety diff --git a/internal/server/action_result_test.go b/internal/server/action_result_test.go index b1253e4..c756610 100644 --- a/internal/server/action_result_test.go +++ b/internal/server/action_result_test.go @@ -322,6 +322,13 @@ func readCacheObject(server *Server, path string) *httptest.ResponseRecorder { return response } +func headCacheObject(server *Server, path string) *httptest.ResponseRecorder { + request := httptest.NewRequest(http.MethodHead, path, nil) + response := httptest.NewRecorder() + server.Handler().ServeHTTP(response, request) + return response +} + func putCacheObject(server *Server, path string, body []byte) *httptest.ResponseRecorder { request := httptest.NewRequest(http.MethodPut, path, bytes.NewReader(body)) response := httptest.NewRecorder() diff --git a/internal/server/action_result_validation.go b/internal/server/action_result_validation.go index e2b8447..4732b14 100644 --- a/internal/server/action_result_validation.go +++ b/internal/server/action_result_validation.go @@ -96,13 +96,24 @@ func (v *actionResultValidator) validateBlob(reference digestReference) error { } v.collect(reference) key := v.server.cfg.KeyPrefix + "-cas-" + reference.hash - found, err := v.casExists(key) + size, found, err := v.casPresence(key) if err != nil { return err } if !found { return missingCASObject(reference) } + // A recorded size that disagrees with the action result means the entry is + // not the blob this action claims to have produced. + if size >= 0 && size != reference.size { + return fmt.Errorf( + "%w: CAS object %s has size %d; action result declares %d", + errInvalidActionResult, + reference.hash, + size, + reference.size, + ) + } return nil } @@ -205,11 +216,15 @@ func (v *actionResultValidator) loadCAS(reference digestReference) (object, erro return cachedObject, nil } -func (v *actionResultValidator) casExists(key string) (bool, error) { +// casPresence reports availability without downloading where the storage mode +// allows it, and the recorded object size when it is known. Publication still +// demands a persisted entry. +func (v *actionResultValidator) casPresence(key string) (int64, bool, error) { if v.requirePersisted { - return v.server.backendExists(v.context, key) + found, err := v.server.backendExists(v.context, key) + return -1, found, err } - return v.server.exists(v.context, key) + return v.server.presence(v.context, key) } func (v *actionResultValidator) reserveObject() error { diff --git a/internal/server/pack_store.go b/internal/server/pack_store.go index ea33f9e..6797dc8 100644 --- a/internal/server/pack_store.go +++ b/internal/server/pack_store.go @@ -30,6 +30,7 @@ type packStore struct { keyPrefix string targetSize int64 flushInterval time.Duration + renewInterval time.Duration maxManifests int mu sync.Mutex @@ -48,8 +49,11 @@ type packStore struct { listedPacks map[string]struct{} packsListed bool missingPacks map[string]struct{} + pendingRenewals map[string]struct{} + renewedPacks map[string]struct{} flushRequests chan struct{} + renewRequests chan struct{} stop chan struct{} closeOnce sync.Once workers sync.WaitGroup @@ -82,6 +86,7 @@ func newPackStore(server *Server) (*packStore, error) { keyPrefix: server.cfg.KeyPrefix, targetSize: server.cfg.PackSize, flushInterval: server.cfg.PackFlushInterval, + renewInterval: server.cfg.PackRenewInterval, maxManifests: server.cfg.MaxManifests, packs: make(map[string]packDescriptor), cas: make(map[string]manifestObject), @@ -94,7 +99,10 @@ func newPackStore(server *Server) (*packStore, error) { loadingPacks: make(map[string]*packLoad), listedPacks: make(map[string]struct{}), missingPacks: make(map[string]struct{}), + pendingRenewals: make(map[string]struct{}), + renewedPacks: make(map[string]struct{}), flushRequests: make(chan struct{}, 1), + renewRequests: make(chan struct{}, 1), stop: make(chan struct{}), } context, cancel := context.WithTimeout(context.Background(), server.cfg.BackendTimeout) @@ -109,6 +117,8 @@ func newPackStore(server *Server) (*packStore, error) { } packs.workers.Add(1) go packs.flushWorker() + packs.workers.Add(1) + go packs.renewWorker() return packs, nil } @@ -135,7 +145,9 @@ func (p *packStore) flushWorker() { func (p *packStore) close(ctx context.Context) error { p.closeOnce.Do(func() { close(p.stop) }) p.workers.Wait() - return p.flush(ctx, true) + err := p.flush(ctx, true) + p.renewPending(ctx) + return err } func (p *packStore) stageCAS(digest string, value object) { @@ -255,9 +267,118 @@ func (p *packStore) resolve(ctx context.Context, key, kind, digest string) (obje return value, true, nil } -func (p *packStore) exists(ctx context.Context, digest string) (bool, error) { - _, found, err := p.resolve(ctx, p.keyPrefix+"-cas-"+digest, "cas", digest) - return found, err +// presence answers a CAS presence check from the manifest view alone, without +// restoring the pack, and schedules a retention renewal for it. +func (p *packStore) presence(digest string) (int64, bool) { + p.mu.Lock() + defer p.mu.Unlock() + entry, found := p.cas[digest] + if !found { + return 0, false + } + if !p.packRestorableLocked(entry.PackID) { + return 0, false + } + p.scheduleRenewalLocked(entry.PackID) + return entry.Size, true +} + +// packRestorableLocked reports whether a pack is still believed to be +// restorable, using only what discovery and earlier downloads already proved. +func (p *packStore) packRestorableLocked(packID string) bool { + if _, loaded := p.loadedPacks[packID]; loaded { + return true + } + if _, missing := p.missingPacks[packID]; missing { + return false + } + if _, known := p.packs[packID]; !known { + return false + } + if _, listed := p.listedPacks[packID]; p.packsListed && !listed { + return false + } + return true +} + +// scheduleRenewalLocked queues one renewal per pack per job. Reading an entry +// is what resets its GitHub retention, so a pack that only ever answers +// presence checks would otherwise be evicted while Bazel still depends on it. +func (p *packStore) scheduleRenewalLocked(packID string) { + if _, renewed := p.renewedPacks[packID]; renewed { + return + } + if _, loaded := p.loadedPacks[packID]; loaded { + return + } + if _, pending := p.pendingRenewals[packID]; pending { + return + } + p.pendingRenewals[packID] = struct{}{} + select { + case p.renewRequests <- struct{}{}: + default: + } +} + +func (p *packStore) renewWorker() { + defer p.workers.Done() + for { + select { + case <-p.stop: + return + case <-p.renewRequests: + } + // Hold the batch briefly: a pack Bazel downloads within the window is + // renewed by that download, which saves the API call entirely. + timer := time.NewTimer(p.renewInterval) + select { + case <-p.stop: + timer.Stop() + return + case <-timer.C: + } + context, cancel := context.WithTimeout(context.Background(), p.server.cfg.BackendTimeout) + p.renewPending(context) + cancel() + } +} + +// renewPending touches each queued pack once. The touch resolves cache +// metadata without transferring the pack, and doubles as a liveness probe. +func (p *packStore) renewPending(ctx context.Context) { + p.mu.Lock() + renewals := make([]packDescriptor, 0, len(p.pendingRenewals)) + for packID := range p.pendingRenewals { + delete(p.pendingRenewals, packID) + if _, renewed := p.renewedPacks[packID]; renewed { + continue + } + descriptor, known := p.packs[packID] + if !known { + continue + } + // Marked before the call so a failing pack is not retried all job. + p.renewedPacks[packID] = struct{}{} + renewals = append(renewals, descriptor) + } + p.mu.Unlock() + + for _, descriptor := range renewals { + found, err := p.server.backendExists(ctx, descriptor.Key) + if err != nil { + p.server.cfg.Logger.Printf("renewing pack %s failed: %s", descriptor.ID, safeError(err)) + continue + } + if !found { + p.mu.Lock() + p.missingPacks[descriptor.ID] = struct{}{} + p.mu.Unlock() + p.server.cfg.Logger.Printf("pack %s vanished before renewal; its entries are cache misses", descriptor.ID) + continue + } + p.server.stats.packRenewals.Add(1) + } } func (p *packStore) materialize(key string, data []byte) (object, error) { @@ -342,6 +463,9 @@ func (p *packStore) loadPack(ctx context.Context, packID string) (string, error) if err == nil { p.loadedPacks[packID] = path loading.path = path + // The download already reset this entry's retention. + p.renewedPacks[packID] = struct{}{} + delete(p.pendingRenewals, packID) } if errors.Is(err, errPackUnavailable) { p.missingPacks[packID] = struct{}{} diff --git a/internal/server/pack_store_test.go b/internal/server/pack_store_test.go index 60230da..6167211 100644 --- a/internal/server/pack_store_test.go +++ b/internal/server/pack_store_test.go @@ -5,6 +5,7 @@ import ( "context" "net/http" "sort" + "strconv" "strings" "testing" "time" @@ -341,6 +342,149 @@ func TestPackedStoreDoesNotSpendTheManifestLimitOnOrphans(t *testing.T) { } } +func TestPackedStorePresenceCheckRenewsPackWithoutDownloadingIt(t *testing.T) { + backend := newMemoryBackend() + seed := testPackedServer(t, backend) + payloads := [][]byte{[]byte("presence one"), []byte("presence two")} + for _, body := range payloads { + if response := putCacheObject(seed, "/cas/"+digest(body), body); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + } + closePackedServer(t, seed) + + restore := testPackedServer(t, backend) + loadsAfterDiscovery := backend.loadCount() + for _, body := range payloads { + response := headCacheObject(restore, "/cas/"+digest(body)) + if response.Code != http.StatusOK { + t.Fatalf("HEAD = %d", response.Code) + } + if got := response.Header().Get("Content-Length"); got != strconv.Itoa(len(body)) { + t.Fatalf("Content-Length = %q", got) + } + if response.Body.Len() != 0 { + t.Fatal("HEAD returned a body") + } + } + if backend.loadCount() != loadsAfterDiscovery { + t.Fatal("a presence check restored the pack") + } + if backend.existsCount() != 0 { + t.Fatal("renewal was issued immediately instead of being batched") + } + + closePackedServer(t, restore) + if backend.existsCount() != 1 { + t.Fatalf("expected one renewal for the shared pack, got %d", backend.existsCount()) + } + if stats := restore.Snapshot(); stats.PackRenewals != 1 || stats.PackDownloads != 0 { + t.Fatalf("unexpected renewal stats: %+v", stats) + } +} + +func TestPackedStoreSkipsRenewalWhenThePackIsDownloaded(t *testing.T) { + backend := newMemoryBackend() + seed := testPackedServer(t, backend) + body := []byte("downloaded soon after") + if response := putCacheObject(seed, "/cas/"+digest(body), body); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, seed) + + restore := testPackedServer(t, backend) + if response := headCacheObject(restore, "/cas/"+digest(body)); response.Code != http.StatusOK { + t.Fatalf("HEAD = %d", response.Code) + } + if response := readCacheObject(restore, "/cas/"+digest(body)); response.Code != http.StatusOK { + t.Fatalf("GET = %d", response.Code) + } + closePackedServer(t, restore) + if backend.existsCount() != 0 { + t.Fatalf("the download should have covered the renewal, got %d calls", backend.existsCount()) + } + if stats := restore.Snapshot(); stats.PackRenewals != 0 || stats.PackDownloads != 1 { + t.Fatalf("unexpected stats: %+v", stats) + } +} + +// seedPackedClosure publishes an output blob and then, in a separate job, an +// action result referencing it, so the two land in different packs. +func seedPackedClosure(t *testing.T, backend *memoryBackend, output []byte, actionDigest string) string { + t.Helper() + reference := referenceFor(output) + blobWriter := testPackedServer(t, backend) + if response := putCacheObject(blobWriter, "/cas/"+reference.hash, output); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, blobWriter) + var blobPackKey string + backend.mu.Lock() + for key := range backend.objects { + if strings.Contains(key, "-car-pack-v1-") { + blobPackKey = key + } + } + backend.mu.Unlock() + if blobPackKey == "" { + t.Fatal("no pack was published for the output") + } + + actionWriter := testPackedServer(t, backend) + if response := putCacheObject(actionWriter, "/ac/"+actionDigest, bytesField(2, outputFileProto(reference, nil))); response.Code != http.StatusNoContent { + t.Fatalf("AC PUT = %d", response.Code) + } + closePackedServer(t, actionWriter) + return blobPackKey +} + +func TestPackedStoreRefusesActionResultWithAnEvictedOutputPack(t *testing.T) { + backend := newMemoryBackend() + actionDigest := digest([]byte("action with evicted output")) + blobPackKey := seedPackedClosure(t, backend, []byte("evicted output"), actionDigest) + + backend.mu.Lock() + delete(backend.objects, blobPackKey) + backend.mu.Unlock() + + restore := testPackedServer(t, backend) + defer closePackedServer(t, restore) + if response := readCacheObject(restore, "/ac/"+actionDigest); response.Code != http.StatusNotFound { + t.Fatalf("action result with an evicted output = %d", response.Code) + } + if stats := restore.Snapshot(); stats.IncompleteActionResults != 1 { + t.Fatalf("closure was not checked before serving: %+v", stats) + } +} + +func TestPackedStoreActionResultHitRenewsItsClosurePacks(t *testing.T) { + backend := newMemoryBackend() + actionDigest := digest([]byte("action with a remote output")) + seedPackedClosure(t, backend, []byte("output kept in another pack"), actionDigest) + // The publishing job presence-checks the output too, so count from here. + renewalsAfterSeeding := backend.existsCount() + + restore := testPackedServer(t, backend) + if response := readCacheObject(restore, "/ac/"+actionDigest); response.Code != http.StatusOK { + t.Fatalf("AC GET = %d", response.Code) + } + stats := restore.Snapshot() + if stats.PackDownloads != 1 || stats.ValidatedActionResults != 1 { + t.Fatalf("serving an action result should restore only its own pack: %+v", stats) + } + if backend.existsCount() != renewalsAfterSeeding { + t.Fatal("renewal was issued immediately instead of being batched") + } + + closePackedServer(t, restore) + if backend.existsCount() != renewalsAfterSeeding+1 { + t.Fatalf("the closure pack was not renewed, got %d calls", backend.existsCount()-renewalsAfterSeeding) + } + if stats := restore.Snapshot(); stats.PackRenewals != 1 { + t.Fatalf("unexpected renewal stats: %+v", stats) + } +} + func TestPackedStoreRejectsConflictingActionResults(t *testing.T) { backend := newMemoryBackend() writerA := testPackedServer(t, backend) diff --git a/internal/server/server.go b/internal/server/server.go index bb8e321..0fe3efd 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -29,6 +29,10 @@ var ( jwtPattern = regexp.MustCompile(`[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}`) ) +// defaultPackRenewInterval batches retention renewals long enough that a pack +// Bazel downloads shortly after a presence check costs no extra API call. +const defaultPackRenewInterval = 15 * time.Second + type Config struct { Backend cache.Backend Catalog cache.Catalog @@ -37,6 +41,7 @@ type Config struct { StorageMode string PackSize int64 PackFlushInterval time.Duration + PackRenewInterval time.Duration MaxManifests int WriteEnabled bool FailOpen bool @@ -110,6 +115,9 @@ func New(cfg Config) (*Server, error) { if cfg.PackFlushInterval <= 0 { return nil, errors.New("pack flush interval must be positive") } + if cfg.PackRenewInterval <= 0 { + cfg.PackRenewInterval = defaultPackRenewInterval + } if cfg.MaxManifests <= 0 { return nil, errors.New("maximum manifests must be positive") } @@ -199,7 +207,9 @@ func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) { } key := s.cfg.KeyPrefix + "-" + kind + "-" + digest switch r.Method { - case http.MethodHead, http.MethodGet: + case http.MethodHead: + s.handleHead(w, r, key, kind, digest) + case http.MethodGet: s.handleRead(w, r, key, kind, digest) case http.MethodPut: s.handlePut(w, r, key, kind, digest) @@ -209,6 +219,30 @@ func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) { } } +// handleHead answers a packed CAS presence check from the manifest view. +// Bazel issues these while building without the bytes, so restoring a whole +// pack to answer one would defeat the point. +func (s *Server) handleHead(w http.ResponseWriter, r *http.Request, key, kind, digest string) { + if s.packs == nil || kind != "cas" { + s.handleRead(w, r, key, kind, digest) + return + } + size, found, err := s.presence(r.Context(), key) + if err != nil || !found { + if err != nil { + s.cfg.Logger.Printf("presence check for cas/%s failed: %s", digest, safeError(err)) + } + s.stats.misses.Add(1) + http.NotFound(w, r) + return + } + s.stats.hits.Add(1) + w.Header().Set("Content-Type", "application/octet-stream") + w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) + w.Header().Set("Cache-Control", "private, max-age=31536000, immutable") + w.WriteHeader(http.StatusOK) +} + func (s *Server) handleImplicitEmptyCASRead(w http.ResponseWriter, r *http.Request) { s.stats.hits.Add(1) w.Header().Set("Content-Type", "application/octet-stream") @@ -401,21 +435,26 @@ func (s *Server) resolve(ctx context.Context, key, kind, digest string) (object, return obj, true, nil } -func (s *Server) exists(ctx context.Context, key string) (bool, error) { +// presence reports whether a CAS object can be served, and its recorded size +// when the storage mode knows that without a download. Packed mode answers +// from the manifest view and renews the holding pack's retention. +func (s *Server) presence(ctx context.Context, key string) (int64, bool, error) { s.objectsMu.RLock() - _, ok := s.objects[key] + object, ok := s.objects[key] s.objectsMu.RUnlock() if ok { - return true, nil + return object.size, true, nil } if s.packs != nil { prefix := s.cfg.KeyPrefix + "-cas-" if !strings.HasPrefix(key, prefix) || len(key) != len(prefix)+64 { - return false, errors.New("packed storage can only resolve CAS keys") + return 0, false, errors.New("packed storage can only resolve CAS keys") } - return s.packs.exists(ctx, key[len(prefix):]) + size, found := s.packs.presence(key[len(prefix):]) + return size, found, nil } - return s.backendExists(ctx, key) + found, err := s.backendExists(ctx, key) + return -1, found, err } func (s *Server) backendExists(ctx context.Context, key string) (bool, error) { diff --git a/internal/server/server_test.go b/internal/server/server_test.go index a7fd7d9..a9712cf 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -20,13 +20,14 @@ import ( ) type memoryBackend struct { - mu sync.Mutex - objects map[string][]byte - loadErr error - existsErr error - saveErr error - saves int - loads int + mu sync.Mutex + objects map[string][]byte + loadErr error + existsErr error + saveErr error + saves int + loads int + existsCalls int } type blockingSaveBackend struct { @@ -74,6 +75,7 @@ func (b *memoryBackend) loadCount() int { func (b *memoryBackend) Exists(_ context.Context, key string) (bool, error) { b.mu.Lock() defer b.mu.Unlock() + b.existsCalls++ if b.existsErr != nil { return false, b.existsErr } @@ -81,6 +83,12 @@ func (b *memoryBackend) Exists(_ context.Context, key string) (bool, error) { return ok, nil } +func (b *memoryBackend) existsCount() int { + b.mu.Lock() + defer b.mu.Unlock() + return b.existsCalls +} + func (b *memoryBackend) Save(_ context.Context, key string, src *os.File, size int64) error { b.mu.Lock() defer b.mu.Unlock() diff --git a/internal/server/stats.go b/internal/server/stats.go index 652d8ce..d58ff03 100644 --- a/internal/server/stats.go +++ b/internal/server/stats.go @@ -29,6 +29,7 @@ type Stats struct { ManifestUploads uint64 `json:"manifest_uploads"` PackDownloads uint64 `json:"pack_downloads"` PackLoadsSkipped uint64 `json:"pack_loads_skipped"` + PackRenewals uint64 `json:"pack_renewals"` PacksDiscovered uint64 `json:"packs_discovered"` ManifestsDiscovered uint64 `json:"manifests_discovered"` ManifestsSkipped uint64 `json:"manifests_skipped"` @@ -61,6 +62,7 @@ type counters struct { manifestUploads atomic.Uint64 packDownloads atomic.Uint64 packLoadsSkipped atomic.Uint64 + packRenewals atomic.Uint64 packsDiscovered atomic.Uint64 manifestsDiscovered atomic.Uint64 manifestsSkipped atomic.Uint64 @@ -94,6 +96,7 @@ func (c *counters) snapshot() Stats { ManifestUploads: c.manifestUploads.Load(), PackDownloads: c.packDownloads.Load(), PackLoadsSkipped: c.packLoadsSkipped.Load(), + PackRenewals: c.packRenewals.Load(), PacksDiscovered: c.packsDiscovered.Load(), ManifestsDiscovered: c.manifestsDiscovered.Load(), ManifestsSkipped: c.manifestsSkipped.Load(), From 1ecf8cf020506f912232f77399a42f2d60f7c02d Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 20 Sep 2026 14:50:03 +1000 Subject: [PATCH 05/55] Support compressing blobs within packs (#6) - Blobs in packs can now be zstd compressed. - Compression is configurable (off/on, level). - New stats for compressed blocks and saved bytes. --- README.md | 29 ++++ action.yml | 8 ++ action/main.js | 5 + action/post.js | 2 + cmd/cache-server/main.go | 40 +++--- docs/carv2-manifest-dag-concept.md | 11 +- go.mod | 5 +- go.sum | 2 + internal/server/block_codec.go | 113 +++++++++++++++ internal/server/block_codec_test.go | 204 ++++++++++++++++++++++++++++ internal/server/manifest.go | 148 ++++++++++++++++---- internal/server/manifest_test.go | 22 ++- internal/server/pack_store.go | 76 +++++++++-- internal/server/pack_store_test.go | 1 + internal/server/server.go | 49 ++++--- internal/server/stats.go | 6 + 16 files changed, 646 insertions(+), 75 deletions(-) create mode 100644 internal/server/block_codec.go create mode 100644 internal/server/block_codec_test.go diff --git a/README.md b/README.md index ba7d43a..47b488b 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,33 @@ uploads the CARv2 file first and the manifest second; the manifest is the commit point. Thus cancellation, eviction, a corrupt pack, or a missing output closure can only lose a cache hit and cannot supply incomplete build output. +### Pack compression + +Nothing between this server and GitHub compresses anything: the cache-v2 client +uploads bytes verbatim and registers the raw length, which is what the 10 GB +repository quota is charged. Pack blocks are therefore compressed here, with +zstd, before upload. + +Compression is per block rather than per pack, so the CARv2 index stays useful: +restoring a pack and serving one object decompresses that object alone instead +of expanding the whole archive. It also lets one pack mix compressed and +verbatim blocks, which matters when a build produces both text and +already-compressed artifacts such as OCI layers. + +A block is stored verbatim when compression cannot pay for itself: below 256 +bytes, or when the result is not at least 5% smaller. Objects larger than 1 MiB +are sampled first, so an incompressible one is rejected after a few hundred KB +rather than after compressing the whole thing. `compressed_blocks` and +`compression_saved_bytes` report the outcome. + +A compressed block is addressed in the pack by the digest of its compressed +bytes, and the manifest records that block CID alongside the object's own CID. +A reader verifies the stored block against the block CID, decompresses it under +a size bound taken from the manifest, and then verifies the result against the +object CID, so a corrupt or truncated block is a cache miss rather than bad +build input. Disabling `pack-compression` stops writing compressed blocks but +never stops reading them. + ### IronMesh example The action can replace the external-cache URL and token in the Bazel job: @@ -176,6 +203,8 @@ Do not enable Bazel remote-cache compression with this release. | `pack-size-mb` | `8` | Target size for a CARv2 archive; only for `packs`, 1–32 MiB | | `pack-flush-seconds` | `30` | Maximum local staging interval; only for `packs` | | `pack-renew-seconds` | `15` | Batching delay for pack retention renewals; only for `packs` | +| `pack-compression` | `true` | Compress pack blocks with zstd; only for `packs` | +| `pack-compression-level` | `3` | zstd level for pack blocks, 1–19; only for `packs` | | `max-manifests` | `2048` | Maximum manifests downloaded during discovery; only for `packs` | | `github-token` | `${{ github.token }}` | `actions: read` token for packed-manifest discovery | | `max-blob-size-mb` | `512` | Maximum spooled upload/download size | diff --git a/action.yml b/action.yml index c5f02b8..e97dd15 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,14 @@ inputs: description: "Seconds that pack retention renewals are batched before being sent; renewals also flush at shutdown" required: false default: "15" + pack-compression: + description: "Compress individual pack blocks with zstd when they shrink meaningfully" + required: false + default: "true" + pack-compression-level: + description: "zstd level used for pack blocks (1-19); higher trades flush time for size" + required: false + default: "3" max-manifests: description: "Maximum manifests to download during discovery; any beyond this are ignored and become cache misses" required: false diff --git a/action/main.js b/action/main.js index a361211..2c98435 100644 --- a/action/main.js +++ b/action/main.js @@ -68,6 +68,8 @@ async function main() { const packSizeMB = positiveInteger("pack-size-mb", 8, 32); const packFlushSeconds = positiveInteger("pack-flush-seconds", 30, 3600); const packRenewSeconds = positiveInteger("pack-renew-seconds", 15, 3600); + const packCompression = parseBoolean(input("pack-compression", "true"), "pack-compression"); + const packCompressionLevel = positiveInteger("pack-compression-level", 3, 19); const maxManifests = positiveInteger("max-manifests", 2048, 10_000); const githubToken = input("github-token", ""); if (storageMode === "packs" && !githubToken) { @@ -105,6 +107,9 @@ async function main() { `${packFlushSeconds}s`, "--pack-renew-interval", `${packRenewSeconds}s`, + booleanFlag("pack-compression", packCompression), + "--pack-compression-level", + String(packCompressionLevel), "--max-manifests", String(maxManifests), booleanFlag("write-enabled", writeEnabled), diff --git a/action/post.js b/action/post.js index 312a9b1..f9369e3 100644 --- a/action/post.js +++ b/action/post.js @@ -75,6 +75,8 @@ async function post() { `| Manifest uploads | ${stats.manifest_uploads ?? 0} |`, `| CARv2 pack downloads | ${stats.pack_downloads ?? 0} |`, `| Pack retention renewals | ${stats.pack_renewals ?? 0} |`, + `| Compressed blocks | ${stats.compressed_blocks ?? 0} |`, + `| Bytes saved by compression | ${stats.compression_saved_bytes ?? 0} |`, `| Unavailable packs skipped | ${stats.pack_loads_skipped ?? 0} |`, `| Packs discovered | ${stats.packs_discovered ?? 0} |`, `| Manifests discovered | ${stats.manifests_discovered ?? 0} |`, diff --git a/cmd/cache-server/main.go b/cmd/cache-server/main.go index 6196954..e7ae96e 100644 --- a/cmd/cache-server/main.go +++ b/cmd/cache-server/main.go @@ -44,6 +44,8 @@ func run() error { packSize = flag.Int64("pack-size", 8*1024*1024, "target CARv2 pack size in bytes") packFlush = flag.Duration("pack-flush-interval", 30*time.Second, "maximum delay before flushing pending CARv2 data") packRenew = flag.Duration("pack-renew-interval", 15*time.Second, "delay before renewing retention for packs that only presence checks touched") + packCompression = flag.Bool("pack-compression", true, "compress individual pack blocks that shrink meaningfully") + packLevel = flag.Int64("pack-compression-level", 3, "zstd level used for pack blocks (1-19)") maxManifests = flag.Int("max-manifests", 2048, "maximum manifests to read during discovery; any beyond this are ignored") writeEnabled = flag.Bool("write-enabled", false, "publish validated uploads") failOpen = flag.Bool("fail-open", true, "degrade backend errors to misses/success") @@ -98,24 +100,26 @@ func run() error { } } srv, err := cacheserver.New(cacheserver.Config{ - Backend: backend, - Catalog: catalog, - CacheDir: dir, - KeyPrefix: *keyPrefix, - StorageMode: *storageMode, - PackSize: *packSize, - PackFlushInterval: *packFlush, - PackRenewInterval: *packRenew, - MaxManifests: *maxManifests, - WriteEnabled: *writeEnabled, - FailOpen: *failOpen, - MaxBlobSize: *maxBlobSize, - MaxConcurrent: *maxConcurrent, - UploadsPerMinute: *uploadsPerMinute, - BackendTimeout: *backendTimeout, - ShutdownToken: os.Getenv("BAZEL_GHA_CACHE_SHUTDOWN_TOKEN"), - Shutdown: requestShutdown, - Logger: logger, + Backend: backend, + Catalog: catalog, + CacheDir: dir, + KeyPrefix: *keyPrefix, + StorageMode: *storageMode, + PackSize: *packSize, + PackFlushInterval: *packFlush, + PackRenewInterval: *packRenew, + PackCompression: *packCompression, + PackCompressionLevel: *packLevel, + MaxManifests: *maxManifests, + WriteEnabled: *writeEnabled, + FailOpen: *failOpen, + MaxBlobSize: *maxBlobSize, + MaxConcurrent: *maxConcurrent, + UploadsPerMinute: *uploadsPerMinute, + BackendTimeout: *backendTimeout, + ShutdownToken: os.Getenv("BAZEL_GHA_CACHE_SHUTDOWN_TOKEN"), + Shutdown: requestShutdown, + Logger: logger, }) if err != nil { return err diff --git a/docs/carv2-manifest-dag-concept.md b/docs/carv2-manifest-dag-concept.md index 313bb2b..b59e6d8 100644 --- a/docs/carv2-manifest-dag-concept.md +++ b/docs/carv2-manifest-dag-concept.md @@ -52,8 +52,15 @@ A pack is an immutable [CARv2][go-car] file produced with - A pack is identified by the SHA-256 of its complete CARv2 bytes and stored under an immutable Actions-cache key such as `-pack-v1-`. -- Packs are not additionally compressed. The GitHub cache transport already - compresses its value. +- Packs are stored uncompressed, and nothing else compresses them either. The + cache-v2 client uploads the bytes verbatim to a block blob with no content + encoding, and finalizes the entry with the raw length, which is what counts + against the repository quota. Individual blocks are therefore compressed with + zstd before they are written into the pack, and the manifest records the + encoding and the CID of the stored bytes. Per-block rather than per-pack + compression keeps the footer index useful, since serving one object + decompresses only that object, and lets a single pack mix compressed and + verbatim blocks. Packs should have a modest target size, initially 8 MiB and at most 32 MiB. Oversized output blobs receive a single-blob pack. GitHub Actions Cache restores diff --git a/go.mod b/go.mod index 2d3d8e5..9a14c7c 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,10 @@ require ( github.com/tonistiigi/go-actions-cache v0.0.0-20260120203934-54bc28c26fd2 ) -require google.golang.org/protobuf v1.36.11 +require ( + github.com/klauspost/compress v1.20.0 + google.golang.org/protobuf v1.36.11 +) require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 // indirect diff --git a/go.sum b/go.sum index 1d8fe7c..8a1de84 100644 --- a/go.sum +++ b/go.sum @@ -67,6 +67,8 @@ github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20250821084354-a425e60cd7 github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20250821084354-a425e60cd714/go.mod h1:ZEUdra3CoqRVRYgAX/jAJO9aZGz6SKtKEG628fHHktY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA= +github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/internal/server/block_codec.go b/internal/server/block_codec.go new file mode 100644 index 0000000..c44bacb --- /dev/null +++ b/internal/server/block_codec.go @@ -0,0 +1,113 @@ +package server + +import ( + "errors" + "fmt" + + "github.com/klauspost/compress/zstd" +) + +// Block encodings recorded in the manifest. An empty encoding means the block +// holds the object's bytes verbatim, which keeps older manifests readable. +const ( + blockEncodingRaw = "" + blockEncodingZstd = "zstd" +) + +const ( + // Below this size a frame header costs more than compression saves. + minCompressibleBlockSize = 256 + // Compressed output must be at least this much smaller to be worth the + // decompression on every later read. + maxUsefulCompressionRatio = 0.95 + // Large objects are sampled first so an incompressible one, such as a + // gzipped OCI layer, is rejected after a few hundred KB rather than after + // compressing hundreds of MB. + compressionProbeSize = 256 << 10 + compressionProbeThreshold = 4 * compressionProbeSize +) + +// blockCodec compresses individual pack blocks. Compressing each block on its +// own keeps the CARv2 index meaningful: a reader restores one block and +// decompresses only that block, instead of expanding a whole pack to serve one +// object. +type blockCodec struct { + encoder *zstd.Encoder + decoder *zstd.Decoder + enabled bool +} + +func newBlockCodec(enabled bool, level, maxBlobSize int64) (*blockCodec, error) { + // Both are safe for concurrent EncodeAll/DecodeAll use. + encoder, err := zstd.NewWriter( + nil, + zstd.WithEncoderLevel(zstd.EncoderLevelFromZstd(int(level))), + zstd.WithEncoderConcurrency(1), + ) + if err != nil { + return nil, fmt.Errorf("create zstd encoder: %w", err) + } + decoder, err := zstd.NewReader( + nil, + zstd.WithDecoderConcurrency(1), + zstd.WithDecoderMaxMemory(uint64(maxBlobSize)), + ) + if err != nil { + return nil, fmt.Errorf("create zstd decoder: %w", err) + } + return &blockCodec{encoder: encoder, decoder: decoder, enabled: enabled}, nil +} + +// encode returns the bytes to store and the encoding to record. It falls back +// to the original bytes whenever compression does not pay for itself. +func (c *blockCodec) encode(data []byte) ([]byte, string) { + if !c.enabled || len(data) < minCompressibleBlockSize { + return data, blockEncodingRaw + } + if len(data) > compressionProbeThreshold && !c.probeWorthwhile(data) { + return data, blockEncodingRaw + } + compressed := c.encoder.EncodeAll(data, nil) + if float64(len(compressed)) > float64(len(data))*maxUsefulCompressionRatio { + return data, blockEncodingRaw + } + return compressed, blockEncodingZstd +} + +func (c *blockCodec) probeWorthwhile(data []byte) bool { + sample := data[:compressionProbeSize] + compressed := c.encoder.EncodeAll(sample, nil) + return float64(len(compressed)) <= float64(len(sample))*maxUsefulCompressionRatio +} + +// decode restores a stored block. plainSize comes from the manifest and bounds +// the output, so a corrupt or hostile frame cannot expand without limit. +func (c *blockCodec) decode(stored []byte, encoding string, plainSize int64) ([]byte, error) { + switch encoding { + case blockEncodingRaw: + return stored, nil + case blockEncodingZstd: + if plainSize < 0 { + return nil, errors.New("compressed block has no declared size") + } + plain, err := c.decoder.DecodeAll(stored, make([]byte, 0, plainSize)) + if err != nil { + return nil, fmt.Errorf("decompress block: %w", err) + } + if int64(len(plain)) != plainSize { + return nil, fmt.Errorf("decompressed block is %d bytes; manifest declares %d", len(plain), plainSize) + } + return plain, nil + default: + return nil, fmt.Errorf("unsupported block encoding %q", encoding) + } +} + +func (c *blockCodec) close() { + _ = c.encoder.Close() + c.decoder.Close() +} + +func validBlockEncoding(encoding string) bool { + return encoding == blockEncodingRaw || encoding == blockEncodingZstd +} diff --git a/internal/server/block_codec_test.go b/internal/server/block_codec_test.go new file mode 100644 index 0000000..db92192 --- /dev/null +++ b/internal/server/block_codec_test.go @@ -0,0 +1,204 @@ +package server + +import ( + "bytes" + "crypto/rand" + "net/http" + "strings" + "testing" + "time" +) + +func testPackedServerWithCompression(t *testing.T, backend *memoryBackend, maxBlobSize int64, enabled bool) *Server { + t.Helper() + return testServer(t, backend, func(cfg *Config) { + cfg.StorageMode = "packs" + cfg.Catalog = memoryCatalog{backend: backend} + cfg.MaxBlobSize = maxBlobSize + cfg.PackSize = maxBlobSize + cfg.PackFlushInterval = time.Hour + cfg.PackCompression = enabled + cfg.MaxManifests = 100 + }) +} + +func packBytes(t *testing.T, backend *memoryBackend) int { + t.Helper() + backend.mu.Lock() + defer backend.mu.Unlock() + total := 0 + for key, value := range backend.objects { + if strings.Contains(key, "-car-pack-v1-") { + total += len(value) + } + } + return total +} + +func TestPackedBlocksAreCompressedAndRestoredExactly(t *testing.T) { + const size = 256 << 10 + payload := bytes.Repeat([]byte("bazel remote cache payload; "), size/28) + backend := newMemoryBackend() + seed := testPackedServerWithCompression(t, backend, 8<<20, true) + if response := putCacheObject(seed, "/cas/"+digest(payload), payload); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, seed) + + stats := seed.Snapshot() + if stats.CompressedBlocks != 1 || stats.CompressionSavedBytes == 0 { + t.Fatalf("block was not compressed: %+v", stats) + } + if stored := packBytes(t, backend); stored >= len(payload)/2 { + t.Fatalf("pack holds %d bytes for a %d byte payload", stored, len(payload)) + } + + restore := testPackedServerWithCompression(t, backend, 8<<20, true) + defer closePackedServer(t, restore) + response := readCacheObject(restore, "/cas/"+digest(payload)) + if response.Code != http.StatusOK { + t.Fatalf("CAS GET = %d", response.Code) + } + if !bytes.Equal(response.Body.Bytes(), payload) { + t.Fatal("restored payload differs from the published payload") + } +} + +func TestPackedIncompressibleBlocksAreStoredVerbatim(t *testing.T) { + payload := make([]byte, 128<<10) + if _, err := rand.Read(payload); err != nil { + t.Fatal(err) + } + backend := newMemoryBackend() + seed := testPackedServerWithCompression(t, backend, 8<<20, true) + if response := putCacheObject(seed, "/cas/"+digest(payload), payload); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, seed) + if stats := seed.Snapshot(); stats.CompressedBlocks != 0 { + t.Fatalf("random data was stored compressed: %+v", stats) + } + + restore := testPackedServerWithCompression(t, backend, 8<<20, true) + defer closePackedServer(t, restore) + response := readCacheObject(restore, "/cas/"+digest(payload)) + if response.Code != http.StatusOK || !bytes.Equal(response.Body.Bytes(), payload) { + t.Fatalf("CAS GET = %d", response.Code) + } +} + +func TestPackedCompressedBlocksAreReadableWithoutCompressionEnabled(t *testing.T) { + payload := bytes.Repeat([]byte("readable by a reader that never compresses; "), 4096) + backend := newMemoryBackend() + seed := testPackedServerWithCompression(t, backend, 8<<20, true) + if response := putCacheObject(seed, "/cas/"+digest(payload), payload); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, seed) + + // Disabling compression must only stop writing it, never stop reading it. + restore := testPackedServerWithCompression(t, backend, 8<<20, false) + defer closePackedServer(t, restore) + response := readCacheObject(restore, "/cas/"+digest(payload)) + if response.Code != http.StatusOK || !bytes.Equal(response.Body.Bytes(), payload) { + t.Fatalf("CAS GET = %d", response.Code) + } +} + +func TestPackedTamperedCompressedBlockIsACacheMiss(t *testing.T) { + payload := bytes.Repeat([]byte("tamper detection through the block CID; "), 4096) + backend := newMemoryBackend() + seed := testPackedServerWithCompression(t, backend, 8<<20, true) + if response := putCacheObject(seed, "/cas/"+digest(payload), payload); response.Code != http.StatusNoContent { + t.Fatalf("CAS PUT = %d", response.Code) + } + closePackedServer(t, seed) + + backend.mu.Lock() + for key, value := range backend.objects { + if strings.Contains(key, "-car-pack-v1-") { + value[len(value)-1] ^= 0xff + } + } + backend.mu.Unlock() + + restore := testPackedServerWithCompression(t, backend, 8<<20, true) + defer closePackedServer(t, restore) + if response := readCacheObject(restore, "/cas/"+digest(payload)); response.Code != http.StatusNotFound { + t.Fatalf("tampered pack = %d", response.Code) + } +} + +func TestBlockCodecSkipsSmallAndIncompressibleInput(t *testing.T) { + codec, err := newBlockCodec(true, defaultPackCompressionLevel, 8<<20) + if err != nil { + t.Fatal(err) + } + defer codec.close() + + small := bytes.Repeat([]byte("a"), minCompressibleBlockSize-1) + if _, encoding := codec.encode(small); encoding != blockEncodingRaw { + t.Fatalf("small input encoding = %q", encoding) + } + random := make([]byte, compressionProbeThreshold+1) + if _, err := rand.Read(random); err != nil { + t.Fatal(err) + } + if _, encoding := codec.encode(random); encoding != blockEncodingRaw { + t.Fatalf("incompressible input encoding = %q", encoding) + } + + compressible := bytes.Repeat([]byte("compress me please "), 1024) + stored, encoding := codec.encode(compressible) + if encoding != blockEncodingZstd || len(stored) >= len(compressible) { + t.Fatalf("compressible input encoding = %q, %d bytes", encoding, len(stored)) + } + plain, err := codec.decode(stored, encoding, int64(len(compressible))) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(plain, compressible) { + t.Fatal("round trip changed the block") + } + if _, err := codec.decode(stored, encoding, int64(len(compressible))-1); err == nil { + t.Fatal("a size disagreeing with the manifest was accepted") + } + if _, err := codec.decode(stored, "brotli", int64(len(compressible))); err == nil { + t.Fatal("an unknown encoding was accepted") + } +} + +func TestManifestFormatOneIsStillReadable(t *testing.T) { + casDigest := digest([]byte("legacy")) + casCID, err := rawCIDForDigest(casDigest) + if err != nil { + t.Fatal(err) + } + packID := digest([]byte("legacy pack")) + legacy := manifest{ + Version: minManifestFormatVersion, + Parents: []string{}, + Packs: []packDescriptor{{ID: packID, Key: packKeyFor("test", packID), Size: 10}}, + CAS: []manifestObject{{ + Digest: casDigest, + CID: casCID.String(), + Block: casCID.String(), + PackID: packID, + Size: 6, + }}, + } + encoded, manifestCID, err := encodeManifest(legacy) + if err != nil { + t.Fatal(err) + } + decoded, err := decodeManifest(encoded, manifestCID) + if err != nil { + t.Fatal(err) + } + if len(decoded.CAS) != 1 { + t.Fatalf("decoded %d CAS entries", len(decoded.CAS)) + } + if decoded.CAS[0].Encoding != blockEncodingRaw || decoded.CAS[0].Block != casCID.String() { + t.Fatalf("format 1 entry did not default to a verbatim block: %+v", decoded.CAS[0]) + } +} diff --git a/internal/server/manifest.go b/internal/server/manifest.go index 3a29ccd..b8c39e3 100644 --- a/internal/server/manifest.go +++ b/internal/server/manifest.go @@ -16,7 +16,12 @@ import ( "github.com/multiformats/go-multihash" ) -const manifestFormatVersion = 1 +// Format 2 adds per-block encoding. Readers still accept format 1, where every +// block is stored verbatim. +const ( + manifestFormatVersion = 2 + minManifestFormatVersion = 1 +) type manifest struct { Version int64 @@ -32,16 +37,22 @@ type packDescriptor struct { Size int64 } +// Block names the stored bytes, which differ from CID when Encoding is set. +// CID always addresses the object itself, so it stays the logical identity. type manifestObject struct { - Digest string - CID string - PackID string - Size int64 + Digest string + CID string + Block string + Encoding string + PackID string + Size int64 } type manifestAction struct { Digest string CID string + Block string + Encoding string PackID string Size int64 ClosurePacks []string @@ -82,7 +93,7 @@ func decodeManifest(data []byte, expectedCID string) (manifest, error) { } func manifestToNode(value manifest) (datamodel.Node, error) { - if value.Version != manifestFormatVersion { + if value.Version < minManifestFormatVersion || value.Version > manifestFormatVersion { return nil, fmt.Errorf("unsupported manifest version %d", value.Version) } parents := append([]string(nil), value.Parents...) @@ -99,10 +110,10 @@ func manifestToNode(value manifest) (datamodel.Node, error) { if err != nil { return nil, err } - if err := assembleManifestActions(assembler, actions); err != nil { + if err := assembleManifestActions(assembler, actions, value.Version); err != nil { return nil, err } - if err := assembleManifestCAS(assembler, cas); err != nil { + if err := assembleManifestCAS(assembler, cas, value.Version); err != nil { return nil, err } if err := assembleManifestPacks(assembler, packs); err != nil { @@ -120,7 +131,7 @@ func manifestToNode(value manifest) (datamodel.Node, error) { return builder.Build(), nil } -func assembleManifestActions(assembler datamodel.MapAssembler, actions []manifestAction) error { +func assembleManifestActions(assembler datamodel.MapAssembler, actions []manifestAction, version int64) error { if err := assembler.AssembleKey().AssignString("actions"); err != nil { return err } @@ -128,18 +139,27 @@ func assembleManifestActions(assembler datamodel.MapAssembler, actions []manifes if err != nil { return err } + encoded := version >= manifestFormatVersion for _, action := range actions { closure := append([]string(nil), action.ClosurePacks...) sort.Strings(closure) - mapAssembler, err := list.AssembleValue().BeginMap(5) - if err != nil { - return err - } - for _, field := range []struct{ key, value string }{ + fields := []struct{ key, value string }{ {"cid", action.CID}, {"digest", action.Digest}, {"pack", action.PackID}, - } { + } + if encoded { + fields = append(fields, + struct{ key, value string }{"block", action.Block}, + struct{ key, value string }{"encoding", action.Encoding}, + ) + } + mapAssembler, err := list.AssembleValue().BeginMap(int64(len(fields)) + 2) + if err != nil { + return err + } + sort.Slice(fields, func(i, j int) bool { return fields[i].key < fields[j].key }) + for _, field := range fields { if err := assembleString(mapAssembler, field.key, field.value); err != nil { return err } @@ -157,7 +177,7 @@ func assembleManifestActions(assembler datamodel.MapAssembler, actions []manifes return list.Finish() } -func assembleManifestCAS(assembler datamodel.MapAssembler, objects []manifestObject) error { +func assembleManifestCAS(assembler datamodel.MapAssembler, objects []manifestObject, version int64) error { if err := assembler.AssembleKey().AssignString("cas"); err != nil { return err } @@ -165,16 +185,25 @@ func assembleManifestCAS(assembler datamodel.MapAssembler, objects []manifestObj if err != nil { return err } + encoded := version >= manifestFormatVersion for _, object := range objects { - mapAssembler, err := list.AssembleValue().BeginMap(4) - if err != nil { - return err - } - for _, field := range []struct{ key, value string }{ + fields := []struct{ key, value string }{ {"cid", object.CID}, {"digest", object.Digest}, {"pack", object.PackID}, - } { + } + if encoded { + fields = append(fields, + struct{ key, value string }{"block", object.Block}, + struct{ key, value string }{"encoding", object.Encoding}, + ) + } + mapAssembler, err := list.AssembleValue().BeginMap(int64(len(fields)) + 1) + if err != nil { + return err + } + sort.Slice(fields, func(i, j int) bool { return fields[i].key < fields[j].key }) + for _, field := range fields { if err := assembleString(mapAssembler, field.key, field.value); err != nil { return err } @@ -256,7 +285,7 @@ func nodeToManifest(node datamodel.Node) (manifest, error) { if err != nil { return manifest{}, err } - if version != manifestFormatVersion { + if version < minManifestFormatVersion || version > manifestFormatVersion { return manifest{}, fmt.Errorf("unsupported manifest version %d", version) } parents, err := nodeStringList(node, "parents") @@ -301,6 +330,9 @@ func (value manifest) validate() error { if !digestPattern.MatchString(object.Digest) || object.Size < 0 || !validRawCID(object.CID, object.Digest) { return errors.New("manifest has invalid CAS entry") } + if err := validateStoredBlock(object.CID, object.Block, object.Encoding); err != nil { + return err + } if _, ok := packIDs[object.PackID]; !ok { return errors.New("CAS entry references an undeclared pack") } @@ -314,6 +346,9 @@ func (value manifest) validate() error { if !digestPattern.MatchString(action.Digest) || action.Size < 0 || !validCID(action.CID) { return errors.New("manifest has invalid action entry") } + if err := validateStoredBlock(action.CID, action.Block, action.Encoding); err != nil { + return err + } if _, ok := packIDs[action.PackID]; !ok { return errors.New("action entry references an undeclared pack") } @@ -417,11 +452,44 @@ func nodeActions(node datamodel.Node) ([]manifestAction, error) { if err != nil { return nil, err } - values = append(values, manifestAction{Digest: digest, CID: contentCID, PackID: packID, Size: size, ClosurePacks: closure}) + block, encoding, err := nodeBlockEncoding(item, contentCID) + if err != nil { + return nil, err + } + values = append(values, manifestAction{ + Digest: digest, + CID: contentCID, + Block: block, + Encoding: encoding, + PackID: packID, + Size: size, + ClosurePacks: closure, + }) } return values, nil } +// nodeBlockEncoding reads the format 2 fields, defaulting to a verbatim block +// so a format 1 manifest keeps working. +func nodeBlockEncoding(node datamodel.Node, contentCID string) (string, string, error) { + encodingNode, err := node.LookupByString("encoding") + if err != nil { + return contentCID, blockEncodingRaw, nil + } + if encodingNode.Kind() != datamodel.Kind_String { + return "", "", errors.New("manifest encoding must be a string") + } + encoding, err := encodingNode.AsString() + if err != nil { + return "", "", err + } + block, err := nodeString(node, "block") + if err != nil { + return "", "", err + } + return block, encoding, nil +} + func nodeObject(node datamodel.Node) (manifestObject, error) { digest, err := nodeString(node, "digest") if err != nil { @@ -439,7 +507,18 @@ func nodeObject(node datamodel.Node) (manifestObject, error) { if err != nil { return manifestObject{}, err } - return manifestObject{Digest: digest, CID: contentCID, PackID: packID, Size: size}, nil + block, encoding, err := nodeBlockEncoding(node, contentCID) + if err != nil { + return manifestObject{}, err + } + return manifestObject{ + Digest: digest, + CID: contentCID, + Block: block, + Encoding: encoding, + PackID: packID, + Size: size, + }, nil } func nodeString(node datamodel.Node, key string) (string, error) { @@ -509,6 +588,25 @@ func validRawCID(value, digest string) bool { return err == nil && value == expected.String() } +// validateStoredBlock keeps the stored block and its encoding consistent: a +// verbatim block is addressed by the object's own CID, and an encoded one must +// name a different block. +func validateStoredBlock(contentCID, block, encoding string) error { + if !validBlockEncoding(encoding) { + return errors.New("manifest has unsupported block encoding") + } + if !validCID(block) { + return errors.New("manifest has invalid stored block CID") + } + if encoding == blockEncodingRaw && block != contentCID { + return errors.New("verbatim block must be addressed by the object CID") + } + if encoding != blockEncodingRaw && block == contentCID { + return errors.New("encoded block must not be addressed by the object CID") + } + return nil +} + func validCID(value string) bool { _, err := cid.Decode(value) return err == nil diff --git a/internal/server/manifest_test.go b/internal/server/manifest_test.go index 5a64449..c95738d 100644 --- a/internal/server/manifest_test.go +++ b/internal/server/manifest_test.go @@ -16,12 +16,30 @@ func TestManifestDAGCBORRoundTripIsDeterministic(t *testing.T) { t.Fatal(err) } packID := digest([]byte("pack")) + compressedCID, err := rawCIDForData([]byte("compressed action bytes")) + if err != nil { + t.Fatal(err) + } value := manifest{ Version: manifestFormatVersion, Parents: []string{}, Packs: []packDescriptor{{ID: packID, Key: packKeyFor("test", packID), Size: 123}}, - CAS: []manifestObject{{Digest: casDigest, CID: casCID.String(), PackID: packID, Size: 3}}, - Actions: []manifestAction{{Digest: digest([]byte("action")), CID: actionCID.String(), PackID: packID, Size: 2, ClosurePacks: []string{packID}}}, + CAS: []manifestObject{{ + Digest: casDigest, + CID: casCID.String(), + Block: casCID.String(), + PackID: packID, + Size: 3, + }}, + Actions: []manifestAction{{ + Digest: digest([]byte("action")), + CID: actionCID.String(), + Block: compressedCID.String(), + Encoding: blockEncodingZstd, + PackID: packID, + Size: 2, + ClosurePacks: []string{packID}, + }}, } encoded, manifestCID, err := encodeManifest(value) if err != nil { diff --git a/internal/server/pack_store.go b/internal/server/pack_store.go index 6797dc8..12e41fe 100644 --- a/internal/server/pack_store.go +++ b/internal/server/pack_store.go @@ -26,6 +26,7 @@ import ( type packStore struct { server *Server catalog cache.Catalog + codec *blockCodec keyPrefix string targetSize int64 @@ -80,9 +81,14 @@ func newPackStore(server *Server) (*packStore, error) { if server.cfg.Catalog == nil { return nil, errors.New("packed storage mode requires a manifest catalog") } + codec, err := newBlockCodec(server.cfg.PackCompression, server.cfg.PackCompressionLevel, server.cfg.MaxBlobSize) + if err != nil { + return nil, err + } packs := &packStore{ server: server, catalog: server.cfg.Catalog, + codec: codec, keyPrefix: server.cfg.KeyPrefix, targetSize: server.cfg.PackSize, flushInterval: server.cfg.PackFlushInterval, @@ -106,7 +112,7 @@ func newPackStore(server *Server) (*packStore, error) { stop: make(chan struct{}), } context, cancel := context.WithTimeout(context.Background(), server.cfg.BackendTimeout) - err := packs.discover(context) + err = packs.discover(context) cancel() if err != nil { server.stats.manifestDiscoveryErrors.Add(1) @@ -147,6 +153,7 @@ func (p *packStore) close(ctx context.Context) error { p.workers.Wait() err := p.flush(ctx, true) p.renewPending(ctx) + p.codec.close() return err } @@ -216,7 +223,7 @@ func (p *packStore) resolve(ctx context.Context, key, kind, digest string) (obje } p.mu.Lock() - var contentCID, packID string + var contentCID, blockCID, encoding, packID string var expectedSize int64 if kind == "cas" { entry, found := p.cas[digest] @@ -224,7 +231,8 @@ func (p *packStore) resolve(ctx context.Context, key, kind, digest string) (obje p.mu.Unlock() return object{}, false, nil } - contentCID, packID, expectedSize = entry.CID, entry.PackID, entry.Size + contentCID, blockCID, encoding = entry.CID, entry.Block, entry.Encoding + packID, expectedSize = entry.PackID, entry.Size } else { if _, conflict := p.actionConflicts[digest]; conflict { p.server.stats.actionDigestConflicts.Add(1) @@ -236,7 +244,8 @@ func (p *packStore) resolve(ctx context.Context, key, kind, digest string) (obje p.mu.Unlock() return object{}, false, nil } - contentCID, packID, expectedSize = entry.CID, entry.PackID, entry.Size + contentCID, blockCID, encoding = entry.CID, entry.Block, entry.Encoding + packID, expectedSize = entry.PackID, entry.Size } p.mu.Unlock() @@ -247,10 +256,23 @@ func (p *packStore) resolve(ctx context.Context, key, kind, digest string) (obje } return object{}, false, err } - data, err := readCARBlock(ctx, path, contentCID, p.server.cfg.MaxBlobSize) + stored, err := readCARBlock(ctx, path, blockCID, p.server.cfg.MaxBlobSize) + if err != nil { + return object{}, false, err + } + data, err := p.codec.decode(stored, encoding, expectedSize) if err != nil { return object{}, false, err } + // The stored block was verified against its own CID; this proves the + // decoded bytes are the object the manifest promised. + decodedCID, err := rawCIDForData(data) + if err != nil { + return object{}, false, err + } + if decodedCID.String() != contentCID { + return object{}, false, fmt.Errorf("packed %s/%s does not match its manifest CID", kind, digest) + } if int64(len(data)) != expectedSize { return object{}, false, fmt.Errorf("packed %s/%s has size %d; manifest declares %d", kind, digest, len(data), expectedSize) } @@ -584,6 +606,22 @@ type packedEntries struct { actions []manifestAction } +// encodeBlock compresses one block and returns the bytes to store, the +// encoding to record, and the CID addressing those bytes. +func (p *packStore) encodeBlock(data []byte, contentCID cid.Cid) ([]byte, string, cid.Cid, error) { + stored, encoding := p.codec.encode(data) + if encoding == blockEncodingRaw { + return data, blockEncodingRaw, contentCID, nil + } + blockCID, err := rawCIDForData(stored) + if err != nil { + return nil, "", cid.Undef, err + } + p.server.stats.compressedBlocks.Add(1) + p.server.stats.compressionSavedBytes.Add(uint64(len(data) - len(stored))) + return stored, encoding, blockCID, nil +} + func (p *packStore) buildPackLocked(ctx context.Context, casDigests, actionDigests []string) (string, packedEntries, int64, string, error) { type blockEntry struct { cid cid.Cid @@ -601,8 +639,18 @@ func (p *packStore) buildPackLocked(ctx context.Context, casDigests, actionDiges if err != nil { return "", packedEntries{}, 0, "", err } - blocksToWrite = append(blocksToWrite, blockEntry{cid: contentCID, data: data}) - entries.cas = append(entries.cas, manifestObject{Digest: digest, CID: contentCID.String(), Size: value.size}) + stored, encoding, blockCID, err := p.encodeBlock(data, contentCID) + if err != nil { + return "", packedEntries{}, 0, "", err + } + blocksToWrite = append(blocksToWrite, blockEntry{cid: blockCID, data: stored}) + entries.cas = append(entries.cas, manifestObject{ + Digest: digest, + CID: contentCID.String(), + Block: blockCID.String(), + Encoding: encoding, + Size: value.size, + }) } for _, digest := range actionDigests { value := p.pendingActions[digest] @@ -614,8 +662,18 @@ func (p *packStore) buildPackLocked(ctx context.Context, casDigests, actionDiges if err != nil { return "", packedEntries{}, 0, "", err } - blocksToWrite = append(blocksToWrite, blockEntry{cid: contentCID, data: data}) - entries.actions = append(entries.actions, manifestAction{Digest: digest, CID: value.cid, Size: value.object.size}) + stored, encoding, blockCID, err := p.encodeBlock(data, contentCID) + if err != nil { + return "", packedEntries{}, 0, "", err + } + blocksToWrite = append(blocksToWrite, blockEntry{cid: blockCID, data: stored}) + entries.actions = append(entries.actions, manifestAction{ + Digest: digest, + CID: value.cid, + Block: blockCID.String(), + Encoding: encoding, + Size: value.object.size, + }) } if len(blocksToWrite) == 0 { return "", packedEntries{}, 0, "", errors.New("cannot build an empty CARv2 pack") diff --git a/internal/server/pack_store_test.go b/internal/server/pack_store_test.go index 6167211..4754542 100644 --- a/internal/server/pack_store_test.go +++ b/internal/server/pack_store_test.go @@ -64,6 +64,7 @@ func testPackedServerWithMaxBlob(t *testing.T, backend *memoryBackend, maxBlobSi cfg.MaxBlobSize = maxBlobSize cfg.PackSize = 1024 cfg.PackFlushInterval = time.Hour + cfg.PackCompression = true cfg.MaxManifests = 100 }) } diff --git a/internal/server/server.go b/internal/server/server.go index 0fe3efd..1be7d84 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -33,25 +33,32 @@ var ( // Bazel downloads shortly after a presence check costs no extra API call. const defaultPackRenewInterval = 15 * time.Second +// defaultPackCompressionLevel favours flush latency over ratio: blocks are +// compressed once on the upload path, and level 3 already captures most of the +// available saving on cache content. +const defaultPackCompressionLevel = 3 + type Config struct { - Backend cache.Backend - Catalog cache.Catalog - CacheDir string - KeyPrefix string - StorageMode string - PackSize int64 - PackFlushInterval time.Duration - PackRenewInterval time.Duration - MaxManifests int - WriteEnabled bool - FailOpen bool - MaxBlobSize int64 - MaxConcurrent int - UploadsPerMinute int - BackendTimeout time.Duration - ShutdownToken string - Shutdown func() - Logger *log.Logger + Backend cache.Backend + Catalog cache.Catalog + CacheDir string + KeyPrefix string + StorageMode string + PackSize int64 + PackFlushInterval time.Duration + PackRenewInterval time.Duration + PackCompression bool + PackCompressionLevel int64 + MaxManifests int + WriteEnabled bool + FailOpen bool + MaxBlobSize int64 + MaxConcurrent int + UploadsPerMinute int + BackendTimeout time.Duration + ShutdownToken string + Shutdown func() + Logger *log.Logger } type object struct { @@ -118,6 +125,12 @@ func New(cfg Config) (*Server, error) { if cfg.PackRenewInterval <= 0 { cfg.PackRenewInterval = defaultPackRenewInterval } + if cfg.PackCompressionLevel == 0 { + cfg.PackCompressionLevel = defaultPackCompressionLevel + } + if cfg.PackCompressionLevel < 1 || cfg.PackCompressionLevel > 19 { + return nil, errors.New("pack compression level must be between 1 and 19") + } if cfg.MaxManifests <= 0 { return nil, errors.New("maximum manifests must be positive") } diff --git a/internal/server/stats.go b/internal/server/stats.go index d58ff03..25730ff 100644 --- a/internal/server/stats.go +++ b/internal/server/stats.go @@ -30,6 +30,8 @@ type Stats struct { PackDownloads uint64 `json:"pack_downloads"` PackLoadsSkipped uint64 `json:"pack_loads_skipped"` PackRenewals uint64 `json:"pack_renewals"` + CompressedBlocks uint64 `json:"compressed_blocks"` + CompressionSavedBytes uint64 `json:"compression_saved_bytes"` PacksDiscovered uint64 `json:"packs_discovered"` ManifestsDiscovered uint64 `json:"manifests_discovered"` ManifestsSkipped uint64 `json:"manifests_skipped"` @@ -63,6 +65,8 @@ type counters struct { packDownloads atomic.Uint64 packLoadsSkipped atomic.Uint64 packRenewals atomic.Uint64 + compressedBlocks atomic.Uint64 + compressionSavedBytes atomic.Uint64 packsDiscovered atomic.Uint64 manifestsDiscovered atomic.Uint64 manifestsSkipped atomic.Uint64 @@ -97,6 +101,8 @@ func (c *counters) snapshot() Stats { PackDownloads: c.packDownloads.Load(), PackLoadsSkipped: c.packLoadsSkipped.Load(), PackRenewals: c.packRenewals.Load(), + CompressedBlocks: c.compressedBlocks.Load(), + CompressionSavedBytes: c.compressionSavedBytes.Load(), PacksDiscovered: c.packsDiscovered.Load(), ManifestsDiscovered: c.manifestsDiscovered.Load(), ManifestsSkipped: c.manifestsSkipped.Load(), From dace1a74e0c4d1fe03e6e163c749751130fb50c7 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 21 Sep 2026 00:41:19 +1000 Subject: [PATCH 06/55] Use "opaque" protobuf API and buf for codegen (#8) --- .gitignore | 1 + README.md | 7 + buf.gen.yaml | 14 + go.mod | 14 +- go.sum | 50 +- .../execution/v2/remote_execution.pb.go | 8259 +++++++++++++++++ .../proto/gen/build/bazel/semver/semver.pb.go | 191 + internal/server/action_result.go | 218 +- internal/server/action_result_test.go | 159 +- internal/server/pack_store_test.go | 4 +- internal/server/reapi_digest.go | 28 + internal/server/reapi_directory.go | 170 +- internal/server/reapi_wire.go | 112 - proto/README.md | 10 + proto/buf.lock | 6 + proto/buf.yaml | 5 + .../execution/v2/remote_execution.proto | 2511 +++++ proto/build/bazel/semver/semver.proto | 41 + scripts/generate-proto.sh | 54 + 19 files changed, 11434 insertions(+), 420 deletions(-) create mode 100644 buf.gen.yaml create mode 100644 internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go create mode 100644 internal/proto/gen/build/bazel/semver/semver.pb.go create mode 100644 internal/server/reapi_digest.go delete mode 100644 internal/server/reapi_wire.go create mode 100644 proto/README.md create mode 100644 proto/buf.lock create mode 100644 proto/buf.yaml create mode 100644 proto/build/bazel/remote/execution/v2/remote_execution.proto create mode 100644 proto/build/bazel/semver/semver.proto create mode 100755 scripts/generate-proto.sh diff --git a/.gitignore b/.gitignore index 65c6f21..e623082 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ coverage.out *.prof dist/*.tmp +.tools/ diff --git a/README.md b/README.md index 47b488b..3b870bf 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,13 @@ validated before use. The repository pins Go in `.go-version` and pins `go-actions-cache` to a full upstream commit through a Go pseudo-version. +REAPI messages are decoded with generated protobuf code (the opaque API of +`google.golang.org/protobuf`). The upstream `.proto` sources are vendored under +`proto/` and the generated Go code is committed under `internal/proto/gen`, so +the commands below need neither `buf` nor `protoc`. Run +`scripts/generate-proto.sh` after changing the vendored definitions or the +pinned generator versions. + ```bash go test -race ./... go vet ./... diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 0000000..891b59e --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,14 @@ +# Generated code is committed to the repository; run scripts/generate-proto.sh to refresh it. +version: v2 +inputs: + - directory: proto +plugins: + # google.golang.org/protobuf >= 1.36 opaque API: struct fields are hidden behind + # accessors, which lets the runtime pick a more compact in-memory layout. + - local: protoc-gen-go + out: internal/proto/gen + opt: + - paths=source_relative + - default_api_level=API_OPAQUE + - Mbuild/bazel/semver/semver.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/semver;semver + - Mbuild/bazel/remote/execution/v2/remote_execution.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2;remoteexecution diff --git a/go.mod b/go.mod index 9a14c7c..d62cc07 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,10 @@ require ( ) require ( + cloud.google.com/go/longrunning v1.2.0 github.com/klauspost/compress v1.20.0 + google.golang.org/genproto/googleapis/api v0.0.0-20260706201446-f0a921348800 + google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 google.golang.org/protobuf v1.36.11 ) @@ -39,12 +42,13 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect github.com/whyrusleeping/cbor-gen v0.3.1 // indirect - golang.org/x/crypto v0.51.0 // indirect + golang.org/x/crypto v0.54.0 // indirect golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect - golang.org/x/net v0.55.0 // indirect - golang.org/x/sync v0.21.0 // indirect - golang.org/x/sys v0.45.0 // indirect - golang.org/x/text v0.39.0 // indirect + golang.org/x/net v0.57.0 // indirect + golang.org/x/sync v0.22.0 // indirect + golang.org/x/sys v0.47.0 // indirect + golang.org/x/text v0.40.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect + google.golang.org/grpc v1.82.0 // indirect lukechampine.com/blake3 v1.4.1 // indirect ) diff --git a/go.sum b/go.sum index 8a1de84..2cabeb8 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +cloud.google.com/go/longrunning v1.2.0 h1:WjYH3YHBGCxGJP9M4dWGHBfXr/cFIjMkNgWcJj7/iMM= +cloud.google.com/go/longrunning v1.2.0/go.mod h1:5KMQALFGOCtFoi2xSOA1u3H7WKlhmckgiyFw7+LGQp0= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 h1:JZg6HRh6W6U4OLl6lk7BZ7BLisIzM9dG1R50zUk9C/M= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0/go.mod h1:YL1xnZ6QejvQHWJrX/AvhFl4WW4rqHVoKspWNVwFk0M= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 h1:B/dfvscEQtew9dVuoxqxrUKKv8Ih2f55PydknDamU+g= @@ -10,6 +12,8 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0 h1:mlmW46Q0B79I+Aj4a github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0/go.mod h1:PXe2h+LKcWTX9afWdZoHyODqR4fBa5boUM/8uJfZ0Jo= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U= @@ -20,8 +24,14 @@ github.com/gammazero/chanqueue v1.1.2 h1:dZEsxlyANZMyeTRemABqZF8QM9BnE4NBI43Oh3y github.com/gammazero/chanqueue v1.1.2/go.mod h1:XDN1X/jjAbmSceNFOQbtKToeSkxtdVdpKu90LiEdBEE= github.com/gammazero/deque v1.2.1 h1:9fnQVFCCZ9/NOc7ccTNqzoKd1tCWOqeI05/lPqFPMGQ= github.com/gammazero/deque v1.2.1/go.mod h1:5nSFkzVm+afG9+gy0VIowlqVAW4N8zNcMne+CMQVD2g= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -127,24 +137,44 @@ github.com/whyrusleeping/cbor-gen v0.3.1 h1:82ioxmhEYut7LBVGhGq8xoRkXPLElVuh5mV6 github.com/whyrusleeping/cbor-gen v0.3.1/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU= +go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc= +go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc= +go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo= +go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58= +go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0= +go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw= +go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A= +go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk= +go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI= -golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8= +golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= +golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= -golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8= -golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww= -golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= -golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= -golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= -golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus= -golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM= +golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= +golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= +golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= +gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= +google.golang.org/genproto/googleapis/api v0.0.0-20260706201446-f0a921348800 h1:admdQBe8jR3VWhBsUrAOaF2Qw6K/+p5pSm1GN8+6Fw4= +google.golang.org/genproto/googleapis/api v0.0.0-20260706201446-f0a921348800/go.mod h1:FPk7EXUKMtImne7AmknoYjT4QXqKIzzRbeQIXzLk6fQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 h1:qEHAMpSaUhtD0p3NbEEI83HwNGFxEwaSJ1G9PLnCBZE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU= +google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go b/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go new file mode 100644 index 0000000..bc80ff6 --- /dev/null +++ b/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go @@ -0,0 +1,8259 @@ +// Copyright 2018 The Bazel Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: build/bazel/remote/execution/v2/remote_execution.proto + +package remoteexecution + +import ( + longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" + semver "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/semver" + _ "google.golang.org/genproto/googleapis/api/annotations" + status "google.golang.org/genproto/googleapis/rpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + durationpb "google.golang.org/protobuf/types/known/durationpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + reflect "reflect" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Command_OutputDirectoryFormat int32 + +const ( + // The client is only interested in receiving output directories in + // the form of a single Tree object, using the `tree_digest` field. + Command_TREE_ONLY Command_OutputDirectoryFormat = 0 + // The client is only interested in receiving output directories in + // the form of a hierarchy of separately stored Directory objects, + // using the `root_directory_digest` field. + Command_DIRECTORY_ONLY Command_OutputDirectoryFormat = 1 + // The client is interested in receiving output directories both in + // the form of a single Tree object and a hierarchy of separately + // stored Directory objects, using both the `tree_digest` and + // `root_directory_digest` fields. + Command_TREE_AND_DIRECTORY Command_OutputDirectoryFormat = 2 +) + +// Enum value maps for Command_OutputDirectoryFormat. +var ( + Command_OutputDirectoryFormat_name = map[int32]string{ + 0: "TREE_ONLY", + 1: "DIRECTORY_ONLY", + 2: "TREE_AND_DIRECTORY", + } + Command_OutputDirectoryFormat_value = map[string]int32{ + "TREE_ONLY": 0, + "DIRECTORY_ONLY": 1, + "TREE_AND_DIRECTORY": 2, + } +) + +func (x Command_OutputDirectoryFormat) Enum() *Command_OutputDirectoryFormat { + p := new(Command_OutputDirectoryFormat) + *p = x + return p +} + +func (x Command_OutputDirectoryFormat) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Command_OutputDirectoryFormat) Descriptor() protoreflect.EnumDescriptor { + return file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[0].Descriptor() +} + +func (Command_OutputDirectoryFormat) Type() protoreflect.EnumType { + return &file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[0] +} + +func (x Command_OutputDirectoryFormat) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +type ExecutionStage_Value int32 + +const ( + // Invalid value. + ExecutionStage_UNKNOWN ExecutionStage_Value = 0 + // Checking the result against the cache. + ExecutionStage_CACHE_CHECK ExecutionStage_Value = 1 + // Currently idle, awaiting a free machine to execute. + ExecutionStage_QUEUED ExecutionStage_Value = 2 + // Currently being executed by a worker. + ExecutionStage_EXECUTING ExecutionStage_Value = 3 + // Finished execution. + ExecutionStage_COMPLETED ExecutionStage_Value = 4 +) + +// Enum value maps for ExecutionStage_Value. +var ( + ExecutionStage_Value_name = map[int32]string{ + 0: "UNKNOWN", + 1: "CACHE_CHECK", + 2: "QUEUED", + 3: "EXECUTING", + 4: "COMPLETED", + } + ExecutionStage_Value_value = map[string]int32{ + "UNKNOWN": 0, + "CACHE_CHECK": 1, + "QUEUED": 2, + "EXECUTING": 3, + "COMPLETED": 4, + } +) + +func (x ExecutionStage_Value) Enum() *ExecutionStage_Value { + p := new(ExecutionStage_Value) + *p = x + return p +} + +func (x ExecutionStage_Value) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ExecutionStage_Value) Descriptor() protoreflect.EnumDescriptor { + return file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[1].Descriptor() +} + +func (ExecutionStage_Value) Type() protoreflect.EnumType { + return &file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[1] +} + +func (x ExecutionStage_Value) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +type DigestFunction_Value int32 + +const ( + // It is an error for the server to return this value. + DigestFunction_UNKNOWN DigestFunction_Value = 0 + // The SHA-256 digest function. + DigestFunction_SHA256 DigestFunction_Value = 1 + // The SHA-1 digest function. + DigestFunction_SHA1 DigestFunction_Value = 2 + // The MD5 digest function. + DigestFunction_MD5 DigestFunction_Value = 3 + // The Microsoft "VSO-Hash" paged SHA256 digest function. + // See https://github.com/microsoft/BuildXL/blob/master/Documentation/Specs/PagedHash.md . + DigestFunction_VSO DigestFunction_Value = 4 + // The SHA-384 digest function. + DigestFunction_SHA384 DigestFunction_Value = 5 + // The SHA-512 digest function. + DigestFunction_SHA512 DigestFunction_Value = 6 + // Murmur3 128-bit digest function, x64 variant. Note that this is not a + // cryptographic hash function and its collision properties are not strongly guaranteed. + // See https://github.com/aappleby/smhasher/wiki/MurmurHash3 . + DigestFunction_MURMUR3 DigestFunction_Value = 7 + // The SHA-256 digest function, modified to use a Merkle tree for + // large objects. This permits implementations to store large blobs + // as a decomposed sequence of 2^j sized chunks, where j >= 10, + // while being able to validate integrity at the chunk level. + // + // Furthermore, on systems that do not offer dedicated instructions + // for computing SHA-256 hashes (e.g., the Intel SHA and ARMv8 + // cryptographic extensions), SHA256TREE hashes can be computed more + // efficiently than plain SHA-256 hashes by using generic SIMD + // extensions, such as Intel AVX2 or ARM NEON. + // + // SHA256TREE hashes are computed as follows: + // + // - For blobs that are 1024 bytes or smaller, the hash is computed + // using the regular SHA-256 digest function. + // + // - For blobs that are more than 1024 bytes in size, the hash is + // computed as follows: + // + // 1. The blob is partitioned into a left (leading) and right + // (trailing) blob. These blobs have lengths m and n + // respectively, where m = 2^k and 0 < n <= m. + // + // 2. Hashes of the left and right blob, Hash(left) and + // Hash(right) respectively, are computed by recursively + // applying the SHA256TREE algorithm. + // + // 3. A single invocation is made to the SHA-256 block cipher with + // the following parameters: + // + // M = Hash(left) || Hash(right) + // H = { + // 0xcbbb9d5d, 0x629a292a, 0x9159015a, 0x152fecd8, + // 0x67332667, 0x8eb44a87, 0xdb0c2e0d, 0x47b5481d, + // } + // + // The values of H are the leading fractional parts of the + // square roots of the 9th to the 16th prime number (23 to 53). + // This differs from plain SHA-256, where the first eight prime + // numbers (2 to 19) are used, thereby preventing trivial hash + // collisions between small and large objects. + // + // 4. The hash of the full blob can then be obtained by + // concatenating the outputs of the block cipher: + // + // Hash(blob) = a || b || c || d || e || f || g || h + // + // Addition of the original values of H, as normally done + // through the use of the Davies-Meyer structure, is not + // performed. This isn't necessary, as the block cipher is only + // invoked once. + // + // Test vectors of this digest function can be found in the + // accompanying sha256tree_test_vectors.txt file. + DigestFunction_SHA256TREE DigestFunction_Value = 8 + // The BLAKE3 hash function. + // See https://github.com/BLAKE3-team/BLAKE3. + DigestFunction_BLAKE3 DigestFunction_Value = 9 + // Identical to SHA1, except that "blob ${sizeBytes}\0" is prepended to + // the blob's contents before hashing, where ${sizeBytes} corresponds to + // the decimal size of the original blob. This allows hashes of files to + // be converted from and to the ones used by the Git version control + // system. + DigestFunction_GITSHA1 DigestFunction_Value = 10 +) + +// Enum value maps for DigestFunction_Value. +var ( + DigestFunction_Value_name = map[int32]string{ + 0: "UNKNOWN", + 1: "SHA256", + 2: "SHA1", + 3: "MD5", + 4: "VSO", + 5: "SHA384", + 6: "SHA512", + 7: "MURMUR3", + 8: "SHA256TREE", + 9: "BLAKE3", + 10: "GITSHA1", + } + DigestFunction_Value_value = map[string]int32{ + "UNKNOWN": 0, + "SHA256": 1, + "SHA1": 2, + "MD5": 3, + "VSO": 4, + "SHA384": 5, + "SHA512": 6, + "MURMUR3": 7, + "SHA256TREE": 8, + "BLAKE3": 9, + "GITSHA1": 10, + } +) + +func (x DigestFunction_Value) Enum() *DigestFunction_Value { + p := new(DigestFunction_Value) + *p = x + return p +} + +func (x DigestFunction_Value) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DigestFunction_Value) Descriptor() protoreflect.EnumDescriptor { + return file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[2].Descriptor() +} + +func (DigestFunction_Value) Type() protoreflect.EnumType { + return &file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[2] +} + +func (x DigestFunction_Value) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +type ChunkingFunction_Value int32 + +const ( + // No specific algorithm. Servers MUST always accept this value. + // For SplitBlob, the server chooses the algorithm. For SpliceBlob, the + // server only verifies that chunks concatenate to form the expected blob. + ChunkingFunction_UNKNOWN ChunkingFunction_Value = 0 + // The FastCDC chunking algorithm as described in the 2020 paper by + // Wen Xia, et al. See https://ieeexplore.ieee.org/document/9055082 + // for details. + ChunkingFunction_FAST_CDC_2020 ChunkingFunction_Value = 1 + // The RepMaxCDC chunking algorithm as implemented by buildbarn/go-cdc. + // See https://github.com/buildbarn/go-cdc for details. + ChunkingFunction_REP_MAX_CDC ChunkingFunction_Value = 2 +) + +// Enum value maps for ChunkingFunction_Value. +var ( + ChunkingFunction_Value_name = map[int32]string{ + 0: "UNKNOWN", + 1: "FAST_CDC_2020", + 2: "REP_MAX_CDC", + } + ChunkingFunction_Value_value = map[string]int32{ + "UNKNOWN": 0, + "FAST_CDC_2020": 1, + "REP_MAX_CDC": 2, + } +) + +func (x ChunkingFunction_Value) Enum() *ChunkingFunction_Value { + p := new(ChunkingFunction_Value) + *p = x + return p +} + +func (x ChunkingFunction_Value) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ChunkingFunction_Value) Descriptor() protoreflect.EnumDescriptor { + return file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[3].Descriptor() +} + +func (ChunkingFunction_Value) Type() protoreflect.EnumType { + return &file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[3] +} + +func (x ChunkingFunction_Value) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +type SymlinkAbsolutePathStrategy_Value int32 + +const ( + // Invalid value. + SymlinkAbsolutePathStrategy_UNKNOWN SymlinkAbsolutePathStrategy_Value = 0 + // Server will return an `INVALID_ARGUMENT` on input symlinks with absolute + // targets. + // If an action tries to create an output symlink with an absolute target, a + // `FAILED_PRECONDITION` will be returned. + SymlinkAbsolutePathStrategy_DISALLOWED SymlinkAbsolutePathStrategy_Value = 1 + // Server will allow symlink targets to escape the input root tree, possibly + // resulting in non-hermetic builds. + SymlinkAbsolutePathStrategy_ALLOWED SymlinkAbsolutePathStrategy_Value = 2 +) + +// Enum value maps for SymlinkAbsolutePathStrategy_Value. +var ( + SymlinkAbsolutePathStrategy_Value_name = map[int32]string{ + 0: "UNKNOWN", + 1: "DISALLOWED", + 2: "ALLOWED", + } + SymlinkAbsolutePathStrategy_Value_value = map[string]int32{ + "UNKNOWN": 0, + "DISALLOWED": 1, + "ALLOWED": 2, + } +) + +func (x SymlinkAbsolutePathStrategy_Value) Enum() *SymlinkAbsolutePathStrategy_Value { + p := new(SymlinkAbsolutePathStrategy_Value) + *p = x + return p +} + +func (x SymlinkAbsolutePathStrategy_Value) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SymlinkAbsolutePathStrategy_Value) Descriptor() protoreflect.EnumDescriptor { + return file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[4].Descriptor() +} + +func (SymlinkAbsolutePathStrategy_Value) Type() protoreflect.EnumType { + return &file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[4] +} + +func (x SymlinkAbsolutePathStrategy_Value) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +type Compressor_Value int32 + +const ( + // No compression. Servers and clients MUST always support this, and do + // not need to advertise it. + Compressor_IDENTITY Compressor_Value = 0 + // Zstandard compression. + Compressor_ZSTD Compressor_Value = 1 + // RFC 1951 Deflate. This format is identical to what is used by ZIP + // files. Headers such as the one generated by gzip are not + // included. + // + // It is advised to use algorithms such as Zstandard instead, as + // those are faster and/or provide a better compression ratio. + Compressor_DEFLATE Compressor_Value = 2 + // Brotli compression. + Compressor_BROTLI Compressor_Value = 3 +) + +// Enum value maps for Compressor_Value. +var ( + Compressor_Value_name = map[int32]string{ + 0: "IDENTITY", + 1: "ZSTD", + 2: "DEFLATE", + 3: "BROTLI", + } + Compressor_Value_value = map[string]int32{ + "IDENTITY": 0, + "ZSTD": 1, + "DEFLATE": 2, + "BROTLI": 3, + } +) + +func (x Compressor_Value) Enum() *Compressor_Value { + p := new(Compressor_Value) + *p = x + return p +} + +func (x Compressor_Value) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Compressor_Value) Descriptor() protoreflect.EnumDescriptor { + return file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[5].Descriptor() +} + +func (Compressor_Value) Type() protoreflect.EnumType { + return &file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes[5] +} + +func (x Compressor_Value) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// An `Action` captures all the information about an execution which is required +// to reproduce it. +// +// `Action`s are the core component of the [Execution] service. A single +// `Action` represents a repeatable action that can be performed by the +// execution service. `Action`s can be succinctly identified by the digest of +// their wire format encoding and, once an `Action` has been executed, will be +// cached in the action cache. Future requests can then use the cached result +// rather than needing to run afresh. +// +// When a server completes execution of an +// [Action][build.bazel.remote.execution.v2.Action], it MAY choose to +// cache the [result][build.bazel.remote.execution.v2.ActionResult] in +// the [ActionCache][build.bazel.remote.execution.v2.ActionCache] unless +// `do_not_cache` is `true`. Clients SHOULD expect the server to do so. By +// default, future calls to +// [Execute][build.bazel.remote.execution.v2.Execution.Execute] the same +// `Action` will also serve their results from the cache. Clients must take care +// to understand the caching behaviour. Ideally, all `Action`s will be +// reproducible so that serving a result from cache is always desirable and +// correct. +type Action struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_CommandDigest *Digest `protobuf:"bytes,1,opt,name=command_digest,json=commandDigest,proto3"` + xxx_hidden_InputRootDigest *Digest `protobuf:"bytes,2,opt,name=input_root_digest,json=inputRootDigest,proto3"` + xxx_hidden_Timeout *durationpb.Duration `protobuf:"bytes,6,opt,name=timeout,proto3"` + xxx_hidden_DoNotCache bool `protobuf:"varint,7,opt,name=do_not_cache,json=doNotCache,proto3"` + xxx_hidden_Salt []byte `protobuf:"bytes,9,opt,name=salt,proto3"` + xxx_hidden_Platform *Platform `protobuf:"bytes,10,opt,name=platform,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Action) Reset() { + *x = Action{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Action) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Action) ProtoMessage() {} + +func (x *Action) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Action) GetCommandDigest() *Digest { + if x != nil { + return x.xxx_hidden_CommandDigest + } + return nil +} + +func (x *Action) GetInputRootDigest() *Digest { + if x != nil { + return x.xxx_hidden_InputRootDigest + } + return nil +} + +func (x *Action) GetTimeout() *durationpb.Duration { + if x != nil { + return x.xxx_hidden_Timeout + } + return nil +} + +func (x *Action) GetDoNotCache() bool { + if x != nil { + return x.xxx_hidden_DoNotCache + } + return false +} + +func (x *Action) GetSalt() []byte { + if x != nil { + return x.xxx_hidden_Salt + } + return nil +} + +func (x *Action) GetPlatform() *Platform { + if x != nil { + return x.xxx_hidden_Platform + } + return nil +} + +func (x *Action) SetCommandDigest(v *Digest) { + x.xxx_hidden_CommandDigest = v +} + +func (x *Action) SetInputRootDigest(v *Digest) { + x.xxx_hidden_InputRootDigest = v +} + +func (x *Action) SetTimeout(v *durationpb.Duration) { + x.xxx_hidden_Timeout = v +} + +func (x *Action) SetDoNotCache(v bool) { + x.xxx_hidden_DoNotCache = v +} + +func (x *Action) SetSalt(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_Salt = v +} + +func (x *Action) SetPlatform(v *Platform) { + x.xxx_hidden_Platform = v +} + +func (x *Action) HasCommandDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_CommandDigest != nil +} + +func (x *Action) HasInputRootDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_InputRootDigest != nil +} + +func (x *Action) HasTimeout() bool { + if x == nil { + return false + } + return x.xxx_hidden_Timeout != nil +} + +func (x *Action) HasPlatform() bool { + if x == nil { + return false + } + return x.xxx_hidden_Platform != nil +} + +func (x *Action) ClearCommandDigest() { + x.xxx_hidden_CommandDigest = nil +} + +func (x *Action) ClearInputRootDigest() { + x.xxx_hidden_InputRootDigest = nil +} + +func (x *Action) ClearTimeout() { + x.xxx_hidden_Timeout = nil +} + +func (x *Action) ClearPlatform() { + x.xxx_hidden_Platform = nil +} + +type Action_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The digest of the [Command][build.bazel.remote.execution.v2.Command] + // to run, which MUST be present in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + CommandDigest *Digest + // The digest of the root + // [Directory][build.bazel.remote.execution.v2.Directory] for the input + // files. The files in the directory tree are available in the correct + // location on the build machine before the command is executed. The root + // directory, as well as every subdirectory and content blob referred to, MUST + // be in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + InputRootDigest *Digest + // A timeout after which the execution should be killed. If the timeout is + // absent, then the client is specifying that the execution should continue + // as long as the server will let it. The server SHOULD impose a timeout if + // the client does not specify one, however, if the client does specify a + // timeout that is longer than the server's maximum timeout, the server MUST + // reject the request. + // + // The timeout is only intended to cover the "execution" of the specified + // action and not time in queue nor any overheads before or after execution + // such as marshalling inputs/outputs. The server SHOULD avoid including time + // spent the client doesn't have control over, and MAY extend or reduce the + // timeout to account for delays or speedups that occur during execution + // itself (e.g., lazily loading data from the Content Addressable Storage, + // live migration of virtual machines, emulation overhead). + // + // The timeout is a part of the + // [Action][build.bazel.remote.execution.v2.Action] message, and + // therefore two `Actions` with different timeouts are different, even if they + // are otherwise identical. This is because, if they were not, running an + // `Action` with a lower timeout than is required might result in a cache hit + // from an execution run with a longer timeout, hiding the fact that the + // timeout is too short. By encoding it directly in the `Action`, a lower + // timeout will result in a cache miss and the execution timeout will fail + // immediately, rather than whenever the cache entry gets evicted. + Timeout *durationpb.Duration + // If true, then the `Action`'s result cannot be cached, and in-flight + // requests for the same `Action` may not be merged. + DoNotCache bool + // An optional additional salt value used to place this `Action` into a + // separate cache namespace from other instances having the same field + // contents. This salt typically comes from operational configuration + // specific to sources such as repo and service configuration, + // and allows disowning an entire set of ActionResults that might have been + // poisoned by buggy software or tool failures. + Salt []byte + // The optional platform requirements for the execution environment. The + // server MAY choose to execute the action on any worker satisfying the + // requirements, so the client SHOULD ensure that running the action on any + // such worker will have the same result. A detailed lexicon for this can be + // found in the accompanying platform.md. + // New in version 2.2: clients SHOULD set these platform properties as well + // as those in the [Command][build.bazel.remote.execution.v2.Command]. Servers + // SHOULD prefer those set here. + Platform *Platform +} + +func (b0 Action_builder) Build() *Action { + m0 := &Action{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_CommandDigest = b.CommandDigest + x.xxx_hidden_InputRootDigest = b.InputRootDigest + x.xxx_hidden_Timeout = b.Timeout + x.xxx_hidden_DoNotCache = b.DoNotCache + x.xxx_hidden_Salt = b.Salt + x.xxx_hidden_Platform = b.Platform + return m0 +} + +// A `Command` is the actual command executed by a worker running an +// [Action][build.bazel.remote.execution.v2.Action] and specifications of its +// environment. +// +// Except as otherwise required, the environment (such as which system +// libraries or binaries are available, and what filesystems are mounted where) +// is defined by and specific to the implementation of the remote execution API. +type Command struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Arguments []string `protobuf:"bytes,1,rep,name=arguments,proto3"` + xxx_hidden_EnvironmentVariables *[]*Command_EnvironmentVariable `protobuf:"bytes,2,rep,name=environment_variables,json=environmentVariables,proto3"` + xxx_hidden_OutputFiles []string `protobuf:"bytes,3,rep,name=output_files,json=outputFiles,proto3"` + xxx_hidden_OutputDirectories []string `protobuf:"bytes,4,rep,name=output_directories,json=outputDirectories,proto3"` + xxx_hidden_OutputPaths []string `protobuf:"bytes,7,rep,name=output_paths,json=outputPaths,proto3"` + xxx_hidden_Platform *Platform `protobuf:"bytes,5,opt,name=platform,proto3"` + xxx_hidden_WorkingDirectory string `protobuf:"bytes,6,opt,name=working_directory,json=workingDirectory,proto3"` + xxx_hidden_OutputNodeProperties []string `protobuf:"bytes,8,rep,name=output_node_properties,json=outputNodeProperties,proto3"` + xxx_hidden_OutputDirectoryFormat Command_OutputDirectoryFormat `protobuf:"varint,9,opt,name=output_directory_format,json=outputDirectoryFormat,proto3,enum=build.bazel.remote.execution.v2.Command_OutputDirectoryFormat"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Command) Reset() { + *x = Command{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Command) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Command) ProtoMessage() {} + +func (x *Command) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Command) GetArguments() []string { + if x != nil { + return x.xxx_hidden_Arguments + } + return nil +} + +func (x *Command) GetEnvironmentVariables() []*Command_EnvironmentVariable { + if x != nil { + if x.xxx_hidden_EnvironmentVariables != nil { + return *x.xxx_hidden_EnvironmentVariables + } + } + return nil +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) GetOutputFiles() []string { + if x != nil { + return x.xxx_hidden_OutputFiles + } + return nil +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) GetOutputDirectories() []string { + if x != nil { + return x.xxx_hidden_OutputDirectories + } + return nil +} + +func (x *Command) GetOutputPaths() []string { + if x != nil { + return x.xxx_hidden_OutputPaths + } + return nil +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) GetPlatform() *Platform { + if x != nil { + return x.xxx_hidden_Platform + } + return nil +} + +func (x *Command) GetWorkingDirectory() string { + if x != nil { + return x.xxx_hidden_WorkingDirectory + } + return "" +} + +func (x *Command) GetOutputNodeProperties() []string { + if x != nil { + return x.xxx_hidden_OutputNodeProperties + } + return nil +} + +func (x *Command) GetOutputDirectoryFormat() Command_OutputDirectoryFormat { + if x != nil { + return x.xxx_hidden_OutputDirectoryFormat + } + return Command_TREE_ONLY +} + +func (x *Command) SetArguments(v []string) { + x.xxx_hidden_Arguments = v +} + +func (x *Command) SetEnvironmentVariables(v []*Command_EnvironmentVariable) { + x.xxx_hidden_EnvironmentVariables = &v +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) SetOutputFiles(v []string) { + x.xxx_hidden_OutputFiles = v +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) SetOutputDirectories(v []string) { + x.xxx_hidden_OutputDirectories = v +} + +func (x *Command) SetOutputPaths(v []string) { + x.xxx_hidden_OutputPaths = v +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) SetPlatform(v *Platform) { + x.xxx_hidden_Platform = v +} + +func (x *Command) SetWorkingDirectory(v string) { + x.xxx_hidden_WorkingDirectory = v +} + +func (x *Command) SetOutputNodeProperties(v []string) { + x.xxx_hidden_OutputNodeProperties = v +} + +func (x *Command) SetOutputDirectoryFormat(v Command_OutputDirectoryFormat) { + x.xxx_hidden_OutputDirectoryFormat = v +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) HasPlatform() bool { + if x == nil { + return false + } + return x.xxx_hidden_Platform != nil +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *Command) ClearPlatform() { + x.xxx_hidden_Platform = nil +} + +type Command_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The arguments to the command. + // + // The first argument specifies the command to run, which may be either an + // absolute path, a path relative to the working directory, or an unqualified + // path (without path separators) which will be resolved using the operating + // system's equivalent of the PATH environment variable. Path separators + // native to the operating system running on the worker SHOULD be used. If the + // `environment_variables` list contains an entry for the PATH environment + // variable, it SHOULD be respected. If not, the resolution process is + // implementation-defined. + // + // Changed in v2.3. v2.2 and older require that no PATH lookups are performed, + // and that relative paths are resolved relative to the input root. This + // behavior can, however, not be relied upon, as most implementations already + // followed the rules described above. + Arguments []string + // The environment variables to set when running the program. The worker may + // provide its own default environment variables; these defaults can be + // overridden using this field. Additional variables can also be specified. + // + // In order to ensure that equivalent + // [Command][build.bazel.remote.execution.v2.Command]s always hash to the same + // value, the environment variables MUST be lexicographically sorted by name. + // Sorting of strings is done by code point, equivalently, by the UTF-8 bytes. + EnvironmentVariables []*Command_EnvironmentVariable + // A list of the output files that the client expects to retrieve from the + // action. Only the listed files, as well as directories listed in + // `output_directories`, will be returned to the client as output. + // Other files or directories that may be created during command execution + // are discarded. + // + // The paths are relative to the working directory of the action execution. + // The paths are specified using a single forward slash (`/`) as a path + // separator, even if the execution platform natively uses a different + // separator. The path MUST NOT include a trailing slash, nor a leading slash, + // being a relative path. + // + // In order to ensure consistent hashing of the same Action, the output paths + // MUST be sorted lexicographically by code point (or, equivalently, by UTF-8 + // bytes). + // + // An output file cannot be duplicated, be a parent of another output file, or + // have the same path as any of the listed output directories. + // + // Directories leading up to the output files are created by the worker prior + // to execution, even if they are not explicitly part of the input root. + // + // DEPRECATED since v2.1: Use `output_paths` instead. + // + // Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. + OutputFiles []string + // A list of the output directories that the client expects to retrieve from + // the action. Only the listed directories will be returned (an entire + // directory structure will be returned as a + // [Tree][build.bazel.remote.execution.v2.Tree] message digest, see + // [OutputDirectory][build.bazel.remote.execution.v2.OutputDirectory]), as + // well as files listed in `output_files`. Other files or directories that + // may be created during command execution are discarded. + // + // The paths are relative to the working directory of the action execution. + // The paths are specified using a single forward slash (`/`) as a path + // separator, even if the execution platform natively uses a different + // separator. The path MUST NOT include a trailing slash, nor a leading slash, + // being a relative path. The special value of empty string is allowed, + // although not recommended, and can be used to capture the entire working + // directory tree, including inputs. + // + // In order to ensure consistent hashing of the same Action, the output paths + // MUST be sorted lexicographically by code point (or, equivalently, by UTF-8 + // bytes). + // + // An output directory cannot be duplicated or have the same path as any of + // the listed output files. An output directory is allowed to be a parent of + // another output directory. + // + // Directories leading up to the output directories (but not the output + // directories themselves) are created by the worker prior to execution, even + // if they are not explicitly part of the input root. + // + // DEPRECATED since 2.1: Use `output_paths` instead. + // + // Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. + OutputDirectories []string + // A list of the output paths that the client expects to retrieve from the + // action. Only the listed paths will be returned to the client as output. + // The type of the output (file or directory) is not specified, and will be + // determined by the server after action execution. If the resulting path is + // a file, it will be returned in an + // [OutputFile][build.bazel.remote.execution.v2.OutputFile] typed field. + // If the path is a directory, the entire directory structure will be returned + // as a [Tree][build.bazel.remote.execution.v2.Tree] message digest, see + // [OutputDirectory][build.bazel.remote.execution.v2.OutputDirectory] + // Other files or directories that may be created during command execution + // are discarded. + // + // The paths are relative to the working directory of the action execution. + // The paths are specified using a single forward slash (`/`) as a path + // separator, even if the execution platform natively uses a different + // separator. The path MUST NOT include a trailing slash, nor a leading slash, + // being a relative path. + // + // In order to ensure consistent hashing of the same Action, the output paths + // MUST be deduplicated and sorted lexicographically by code point (or, + // equivalently, by UTF-8 bytes). + // + // Directories leading up to the output paths are created by the worker prior + // to execution, even if they are not explicitly part of the input root. + // + // New in v2.1: this field supersedes the DEPRECATED `output_files` and + // `output_directories` fields. If `output_paths` is used, `output_files` and + // `output_directories` will be ignored! + OutputPaths []string + // The platform requirements for the execution environment. The server MAY + // choose to execute the action on any worker satisfying the requirements, so + // the client SHOULD ensure that running the action on any such worker will + // have the same result. A detailed lexicon for this can be found in the + // accompanying platform.md. + // DEPRECATED as of v2.2: platform properties are now specified directly in + // the action. See documentation note in the + // [Action][build.bazel.remote.execution.v2.Action] for migration. + // + // Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. + Platform *Platform + // The working directory, relative to the input root, for the command to run + // in. It must be a directory which exists in the input tree. If it is left + // empty, then the action is run in the input root. + WorkingDirectory string + // A list of keys for node properties the client expects to retrieve for + // output files and directories. Keys are either names of string-based + // [NodeProperty][build.bazel.remote.execution.v2.NodeProperty] or + // names of fields in [NodeProperties][build.bazel.remote.execution.v2.NodeProperties]. + // In order to ensure that equivalent `Action`s always hash to the same + // value, the node properties MUST be lexicographically sorted by name. + // Sorting of strings is done by code point, equivalently, by the UTF-8 bytes. + // + // The interpretation of string-based properties is server-dependent. If a + // property is not recognized by the server, the server will return an + // `INVALID_ARGUMENT`. + OutputNodeProperties []string + // The format that the worker should use to store the contents of + // output directories. + // + // In case this field is set to a value that is not supported by the + // worker, the worker SHOULD interpret this field as TREE_ONLY. The + // worker MAY store output directories in formats that are a superset + // of what was requested (e.g., interpreting DIRECTORY_ONLY as + // TREE_AND_DIRECTORY). + OutputDirectoryFormat Command_OutputDirectoryFormat +} + +func (b0 Command_builder) Build() *Command { + m0 := &Command{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Arguments = b.Arguments + x.xxx_hidden_EnvironmentVariables = &b.EnvironmentVariables + x.xxx_hidden_OutputFiles = b.OutputFiles + x.xxx_hidden_OutputDirectories = b.OutputDirectories + x.xxx_hidden_OutputPaths = b.OutputPaths + x.xxx_hidden_Platform = b.Platform + x.xxx_hidden_WorkingDirectory = b.WorkingDirectory + x.xxx_hidden_OutputNodeProperties = b.OutputNodeProperties + x.xxx_hidden_OutputDirectoryFormat = b.OutputDirectoryFormat + return m0 +} + +// A `Platform` is a set of requirements, such as hardware, operating system, or +// compiler toolchain, for an +// [Action][build.bazel.remote.execution.v2.Action]'s execution +// environment. A `Platform` is represented as a series of key-value pairs +// representing the properties that are required of the platform. +type Platform struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Properties *[]*Platform_Property `protobuf:"bytes,1,rep,name=properties,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Platform) Reset() { + *x = Platform{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Platform) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Platform) ProtoMessage() {} + +func (x *Platform) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Platform) GetProperties() []*Platform_Property { + if x != nil { + if x.xxx_hidden_Properties != nil { + return *x.xxx_hidden_Properties + } + } + return nil +} + +func (x *Platform) SetProperties(v []*Platform_Property) { + x.xxx_hidden_Properties = &v +} + +type Platform_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The properties that make up this platform. In order to ensure that + // equivalent `Platform`s always hash to the same value, the properties MUST + // be lexicographically sorted by name, and then by value. Sorting of strings + // is done by code point, equivalently, by the UTF-8 bytes. + Properties []*Platform_Property +} + +func (b0 Platform_builder) Build() *Platform { + m0 := &Platform{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Properties = &b.Properties + return m0 +} + +// A `Directory` represents a directory node in a file tree, containing zero or +// more children [FileNodes][build.bazel.remote.execution.v2.FileNode], +// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode] and +// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. +// Each `Node` contains its name in the directory, either the digest of its +// content (either a file blob or a `Directory` proto) or a symlink target, as +// well as possibly some metadata about the file or directory. +// +// In order to ensure that two equivalent directory trees hash to the same +// value, the following restrictions MUST be obeyed when constructing +// a `Directory`: +// +// - Every child in the directory must have a path of exactly one segment. +// Multiple levels of directory hierarchy may not be collapsed. +// - Each child in the directory must have a unique path segment (file name). +// Note that while the API itself is case-sensitive, the environment where +// the Action is executed may or may not be case-sensitive. That is, it is +// legal to call the API with a Directory that has both "Foo" and "foo" as +// children, but the Action may be rejected by the remote system upon +// execution. +// - The files, directories and symlinks in the directory must each be sorted +// in lexicographical order by path. The path strings must be sorted by code +// point, equivalently, by UTF-8 bytes. +// - The [NodeProperties][build.bazel.remote.execution.v2.NodeProperty] of files, +// directories, and symlinks must be sorted in lexicographical order by +// property name. +// +// A `Directory` that obeys the restrictions is said to be in canonical form. +// +// As an example, the following could be used for a file named `bar` and a +// directory named `foo` with an executable file named `baz` (hashes shortened +// for readability): +// +// ```json +// // (Directory proto) +// +// { +// files: [ +// { +// name: "bar", +// digest: { +// hash: "4a73bc9d03...", +// size: 65534 +// }, +// node_properties: [ +// { +// "name": "MTime", +// "value": "2017-01-15T01:30:15.01Z" +// } +// ] +// } +// ], +// directories: [ +// { +// name: "foo", +// digest: { +// hash: "4cf2eda940...", +// size: 43 +// } +// } +// ] +// } +// +// // (Directory proto with hash "4cf2eda940..." and size 43) +// +// { +// files: [ +// { +// name: "baz", +// digest: { +// hash: "b2c941073e...", +// size: 1294, +// }, +// is_executable: true +// } +// ] +// } +// +// ``` +type Directory struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Files *[]*FileNode `protobuf:"bytes,1,rep,name=files,proto3"` + xxx_hidden_Directories *[]*DirectoryNode `protobuf:"bytes,2,rep,name=directories,proto3"` + xxx_hidden_Symlinks *[]*SymlinkNode `protobuf:"bytes,3,rep,name=symlinks,proto3"` + xxx_hidden_NodeProperties *NodeProperties `protobuf:"bytes,5,opt,name=node_properties,json=nodeProperties,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Directory) Reset() { + *x = Directory{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Directory) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Directory) ProtoMessage() {} + +func (x *Directory) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Directory) GetFiles() []*FileNode { + if x != nil { + if x.xxx_hidden_Files != nil { + return *x.xxx_hidden_Files + } + } + return nil +} + +func (x *Directory) GetDirectories() []*DirectoryNode { + if x != nil { + if x.xxx_hidden_Directories != nil { + return *x.xxx_hidden_Directories + } + } + return nil +} + +func (x *Directory) GetSymlinks() []*SymlinkNode { + if x != nil { + if x.xxx_hidden_Symlinks != nil { + return *x.xxx_hidden_Symlinks + } + } + return nil +} + +func (x *Directory) GetNodeProperties() *NodeProperties { + if x != nil { + return x.xxx_hidden_NodeProperties + } + return nil +} + +func (x *Directory) SetFiles(v []*FileNode) { + x.xxx_hidden_Files = &v +} + +func (x *Directory) SetDirectories(v []*DirectoryNode) { + x.xxx_hidden_Directories = &v +} + +func (x *Directory) SetSymlinks(v []*SymlinkNode) { + x.xxx_hidden_Symlinks = &v +} + +func (x *Directory) SetNodeProperties(v *NodeProperties) { + x.xxx_hidden_NodeProperties = v +} + +func (x *Directory) HasNodeProperties() bool { + if x == nil { + return false + } + return x.xxx_hidden_NodeProperties != nil +} + +func (x *Directory) ClearNodeProperties() { + x.xxx_hidden_NodeProperties = nil +} + +type Directory_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The files in the directory. + Files []*FileNode + // The subdirectories in the directory. + Directories []*DirectoryNode + // The symlinks in the directory. + Symlinks []*SymlinkNode + NodeProperties *NodeProperties +} + +func (b0 Directory_builder) Build() *Directory { + m0 := &Directory{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Files = &b.Files + x.xxx_hidden_Directories = &b.Directories + x.xxx_hidden_Symlinks = &b.Symlinks + x.xxx_hidden_NodeProperties = b.NodeProperties + return m0 +} + +// A single property for [FileNodes][build.bazel.remote.execution.v2.FileNode], +// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode], and +// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. The server is +// responsible for specifying the property `name`s that it accepts. If +// permitted by the server, the same `name` may occur multiple times. +type NodeProperty struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3"` + xxx_hidden_Value string `protobuf:"bytes,2,opt,name=value,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NodeProperty) Reset() { + *x = NodeProperty{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NodeProperty) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeProperty) ProtoMessage() {} + +func (x *NodeProperty) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *NodeProperty) GetName() string { + if x != nil { + return x.xxx_hidden_Name + } + return "" +} + +func (x *NodeProperty) GetValue() string { + if x != nil { + return x.xxx_hidden_Value + } + return "" +} + +func (x *NodeProperty) SetName(v string) { + x.xxx_hidden_Name = v +} + +func (x *NodeProperty) SetValue(v string) { + x.xxx_hidden_Value = v +} + +type NodeProperty_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The property name. + Name string + // The property value. + Value string +} + +func (b0 NodeProperty_builder) Build() *NodeProperty { + m0 := &NodeProperty{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + x.xxx_hidden_Value = b.Value + return m0 +} + +// Node properties for [FileNodes][build.bazel.remote.execution.v2.FileNode], +// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode], and +// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. The server is +// responsible for specifying the properties that it accepts. +type NodeProperties struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Properties *[]*NodeProperty `protobuf:"bytes,1,rep,name=properties,proto3"` + xxx_hidden_Mtime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=mtime,proto3"` + xxx_hidden_UnixMode *wrapperspb.UInt32Value `protobuf:"bytes,3,opt,name=unix_mode,json=unixMode,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NodeProperties) Reset() { + *x = NodeProperties{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NodeProperties) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeProperties) ProtoMessage() {} + +func (x *NodeProperties) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *NodeProperties) GetProperties() []*NodeProperty { + if x != nil { + if x.xxx_hidden_Properties != nil { + return *x.xxx_hidden_Properties + } + } + return nil +} + +func (x *NodeProperties) GetMtime() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_Mtime + } + return nil +} + +func (x *NodeProperties) GetUnixMode() *wrapperspb.UInt32Value { + if x != nil { + return x.xxx_hidden_UnixMode + } + return nil +} + +func (x *NodeProperties) SetProperties(v []*NodeProperty) { + x.xxx_hidden_Properties = &v +} + +func (x *NodeProperties) SetMtime(v *timestamppb.Timestamp) { + x.xxx_hidden_Mtime = v +} + +func (x *NodeProperties) SetUnixMode(v *wrapperspb.UInt32Value) { + x.xxx_hidden_UnixMode = v +} + +func (x *NodeProperties) HasMtime() bool { + if x == nil { + return false + } + return x.xxx_hidden_Mtime != nil +} + +func (x *NodeProperties) HasUnixMode() bool { + if x == nil { + return false + } + return x.xxx_hidden_UnixMode != nil +} + +func (x *NodeProperties) ClearMtime() { + x.xxx_hidden_Mtime = nil +} + +func (x *NodeProperties) ClearUnixMode() { + x.xxx_hidden_UnixMode = nil +} + +type NodeProperties_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // A list of string-based + // [NodeProperties][build.bazel.remote.execution.v2.NodeProperty]. + Properties []*NodeProperty + // The file's last modification timestamp. + Mtime *timestamppb.Timestamp + // The UNIX file mode, e.g., 0755. + UnixMode *wrapperspb.UInt32Value +} + +func (b0 NodeProperties_builder) Build() *NodeProperties { + m0 := &NodeProperties{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Properties = &b.Properties + x.xxx_hidden_Mtime = b.Mtime + x.xxx_hidden_UnixMode = b.UnixMode + return m0 +} + +// A `FileNode` represents a single file and associated metadata. +type FileNode struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3"` + xxx_hidden_Digest *Digest `protobuf:"bytes,2,opt,name=digest,proto3"` + xxx_hidden_IsExecutable bool `protobuf:"varint,4,opt,name=is_executable,json=isExecutable,proto3"` + xxx_hidden_NodeProperties *NodeProperties `protobuf:"bytes,6,opt,name=node_properties,json=nodeProperties,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *FileNode) Reset() { + *x = FileNode{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FileNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FileNode) ProtoMessage() {} + +func (x *FileNode) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *FileNode) GetName() string { + if x != nil { + return x.xxx_hidden_Name + } + return "" +} + +func (x *FileNode) GetDigest() *Digest { + if x != nil { + return x.xxx_hidden_Digest + } + return nil +} + +func (x *FileNode) GetIsExecutable() bool { + if x != nil { + return x.xxx_hidden_IsExecutable + } + return false +} + +func (x *FileNode) GetNodeProperties() *NodeProperties { + if x != nil { + return x.xxx_hidden_NodeProperties + } + return nil +} + +func (x *FileNode) SetName(v string) { + x.xxx_hidden_Name = v +} + +func (x *FileNode) SetDigest(v *Digest) { + x.xxx_hidden_Digest = v +} + +func (x *FileNode) SetIsExecutable(v bool) { + x.xxx_hidden_IsExecutable = v +} + +func (x *FileNode) SetNodeProperties(v *NodeProperties) { + x.xxx_hidden_NodeProperties = v +} + +func (x *FileNode) HasDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_Digest != nil +} + +func (x *FileNode) HasNodeProperties() bool { + if x == nil { + return false + } + return x.xxx_hidden_NodeProperties != nil +} + +func (x *FileNode) ClearDigest() { + x.xxx_hidden_Digest = nil +} + +func (x *FileNode) ClearNodeProperties() { + x.xxx_hidden_NodeProperties = nil +} + +type FileNode_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the file. + Name string + // The digest of the file's content. + Digest *Digest + // True if file is executable, false otherwise. + IsExecutable bool + NodeProperties *NodeProperties +} + +func (b0 FileNode_builder) Build() *FileNode { + m0 := &FileNode{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + x.xxx_hidden_Digest = b.Digest + x.xxx_hidden_IsExecutable = b.IsExecutable + x.xxx_hidden_NodeProperties = b.NodeProperties + return m0 +} + +// A `DirectoryNode` represents a child of a +// [Directory][build.bazel.remote.execution.v2.Directory] which is itself +// a `Directory` and its associated metadata. +type DirectoryNode struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3"` + xxx_hidden_Digest *Digest `protobuf:"bytes,2,opt,name=digest,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DirectoryNode) Reset() { + *x = DirectoryNode{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DirectoryNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DirectoryNode) ProtoMessage() {} + +func (x *DirectoryNode) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *DirectoryNode) GetName() string { + if x != nil { + return x.xxx_hidden_Name + } + return "" +} + +func (x *DirectoryNode) GetDigest() *Digest { + if x != nil { + return x.xxx_hidden_Digest + } + return nil +} + +func (x *DirectoryNode) SetName(v string) { + x.xxx_hidden_Name = v +} + +func (x *DirectoryNode) SetDigest(v *Digest) { + x.xxx_hidden_Digest = v +} + +func (x *DirectoryNode) HasDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_Digest != nil +} + +func (x *DirectoryNode) ClearDigest() { + x.xxx_hidden_Digest = nil +} + +type DirectoryNode_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the directory. + Name string + // The digest of the + // [Directory][build.bazel.remote.execution.v2.Directory] object + // represented. See [Digest][build.bazel.remote.execution.v2.Digest] + // for information about how to take the digest of a proto message. + Digest *Digest +} + +func (b0 DirectoryNode_builder) Build() *DirectoryNode { + m0 := &DirectoryNode{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + x.xxx_hidden_Digest = b.Digest + return m0 +} + +// A `SymlinkNode` represents a symbolic link. +type SymlinkNode struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3"` + xxx_hidden_Target string `protobuf:"bytes,2,opt,name=target,proto3"` + xxx_hidden_NodeProperties *NodeProperties `protobuf:"bytes,4,opt,name=node_properties,json=nodeProperties,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SymlinkNode) Reset() { + *x = SymlinkNode{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SymlinkNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SymlinkNode) ProtoMessage() {} + +func (x *SymlinkNode) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SymlinkNode) GetName() string { + if x != nil { + return x.xxx_hidden_Name + } + return "" +} + +func (x *SymlinkNode) GetTarget() string { + if x != nil { + return x.xxx_hidden_Target + } + return "" +} + +func (x *SymlinkNode) GetNodeProperties() *NodeProperties { + if x != nil { + return x.xxx_hidden_NodeProperties + } + return nil +} + +func (x *SymlinkNode) SetName(v string) { + x.xxx_hidden_Name = v +} + +func (x *SymlinkNode) SetTarget(v string) { + x.xxx_hidden_Target = v +} + +func (x *SymlinkNode) SetNodeProperties(v *NodeProperties) { + x.xxx_hidden_NodeProperties = v +} + +func (x *SymlinkNode) HasNodeProperties() bool { + if x == nil { + return false + } + return x.xxx_hidden_NodeProperties != nil +} + +func (x *SymlinkNode) ClearNodeProperties() { + x.xxx_hidden_NodeProperties = nil +} + +type SymlinkNode_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the symlink. + Name string + // The target path of the symlink. The path separator is a forward slash `/`. + // The target path can be relative to the parent directory of the symlink or + // it can be an absolute path starting with `/`. Support for absolute paths + // can be checked using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] + // API. `..` components are allowed anywhere in the target path as logical + // canonicalization may lead to different behavior in the presence of + // directory symlinks (e.g. `foo/../bar` may not be the same as `bar`). + // To reduce potential cache misses, canonicalization is still recommended + // where this is possible without impacting correctness. + Target string + NodeProperties *NodeProperties +} + +func (b0 SymlinkNode_builder) Build() *SymlinkNode { + m0 := &SymlinkNode{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + x.xxx_hidden_Target = b.Target + x.xxx_hidden_NodeProperties = b.NodeProperties + return m0 +} + +// A content digest. A digest for a given blob consists of the size of the blob +// and its hash. The hash algorithm to use is defined by the server. +// +// The size is considered to be an integral part of the digest and cannot be +// separated. That is, even if the `hash` field is correctly specified but +// `size_bytes` is not, the server MUST reject the request. +// +// The reason for including the size in the digest is as follows: in a great +// many cases, the server needs to know the size of the blob it is about to work +// with prior to starting an operation with it, such as flattening Merkle tree +// structures or streaming it to a worker. Technically, the server could +// implement a separate metadata store, but this results in a significantly more +// complicated implementation as opposed to having the client specify the size +// up-front (or storing the size along with the digest in every message where +// digests are embedded). This does mean that the API leaks some implementation +// details of (what we consider to be) a reasonable server implementation, but +// we consider this to be a worthwhile tradeoff. +// +// When a `Digest` is used to refer to a proto message, it always refers to the +// message in binary encoded form. To ensure consistent hashing, clients and +// servers MUST ensure that they serialize messages according to the following +// rules, even if there are alternate valid encodings for the same message: +// +// * Fields are serialized in tag order. +// * There are no unknown fields. +// * There are no duplicate fields. +// * Fields are serialized according to the default semantics for their type. +// +// Most protocol buffer implementations will always follow these rules when +// serializing, but care should be taken to avoid shortcuts. For instance, +// concatenating two messages to merge them may produce duplicate fields. +type Digest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Hash string `protobuf:"bytes,1,opt,name=hash,proto3"` + xxx_hidden_SizeBytes int64 `protobuf:"varint,2,opt,name=size_bytes,json=sizeBytes,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Digest) Reset() { + *x = Digest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Digest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Digest) ProtoMessage() {} + +func (x *Digest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Digest) GetHash() string { + if x != nil { + return x.xxx_hidden_Hash + } + return "" +} + +func (x *Digest) GetSizeBytes() int64 { + if x != nil { + return x.xxx_hidden_SizeBytes + } + return 0 +} + +func (x *Digest) SetHash(v string) { + x.xxx_hidden_Hash = v +} + +func (x *Digest) SetSizeBytes(v int64) { + x.xxx_hidden_SizeBytes = v +} + +type Digest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The hash, represented as a lowercase hexadecimal string, padded with + // leading zeroes up to the hash function length. + Hash string + // The size of the blob, in bytes. + SizeBytes int64 +} + +func (b0 Digest_builder) Build() *Digest { + m0 := &Digest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Hash = b.Hash + x.xxx_hidden_SizeBytes = b.SizeBytes + return m0 +} + +// ExecutedActionMetadata contains details about a completed execution. +type ExecutedActionMetadata struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Worker string `protobuf:"bytes,1,opt,name=worker,proto3"` + xxx_hidden_QueuedTimestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=queued_timestamp,json=queuedTimestamp,proto3"` + xxx_hidden_WorkerStartTimestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=worker_start_timestamp,json=workerStartTimestamp,proto3"` + xxx_hidden_WorkerCompletedTimestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=worker_completed_timestamp,json=workerCompletedTimestamp,proto3"` + xxx_hidden_InputFetchStartTimestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=input_fetch_start_timestamp,json=inputFetchStartTimestamp,proto3"` + xxx_hidden_InputFetchCompletedTimestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=input_fetch_completed_timestamp,json=inputFetchCompletedTimestamp,proto3"` + xxx_hidden_ExecutionStartTimestamp *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=execution_start_timestamp,json=executionStartTimestamp,proto3"` + xxx_hidden_ExecutionCompletedTimestamp *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=execution_completed_timestamp,json=executionCompletedTimestamp,proto3"` + xxx_hidden_VirtualExecutionDuration *durationpb.Duration `protobuf:"bytes,12,opt,name=virtual_execution_duration,json=virtualExecutionDuration,proto3"` + xxx_hidden_OutputUploadStartTimestamp *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=output_upload_start_timestamp,json=outputUploadStartTimestamp,proto3"` + xxx_hidden_OutputUploadCompletedTimestamp *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=output_upload_completed_timestamp,json=outputUploadCompletedTimestamp,proto3"` + xxx_hidden_AuxiliaryMetadata *[]*anypb.Any `protobuf:"bytes,11,rep,name=auxiliary_metadata,json=auxiliaryMetadata,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutedActionMetadata) Reset() { + *x = ExecutedActionMetadata{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutedActionMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutedActionMetadata) ProtoMessage() {} + +func (x *ExecutedActionMetadata) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ExecutedActionMetadata) GetWorker() string { + if x != nil { + return x.xxx_hidden_Worker + } + return "" +} + +func (x *ExecutedActionMetadata) GetQueuedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_QueuedTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetWorkerStartTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_WorkerStartTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetWorkerCompletedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_WorkerCompletedTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetInputFetchStartTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_InputFetchStartTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetInputFetchCompletedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_InputFetchCompletedTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetExecutionStartTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_ExecutionStartTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetExecutionCompletedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_ExecutionCompletedTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetVirtualExecutionDuration() *durationpb.Duration { + if x != nil { + return x.xxx_hidden_VirtualExecutionDuration + } + return nil +} + +func (x *ExecutedActionMetadata) GetOutputUploadStartTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_OutputUploadStartTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetOutputUploadCompletedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_OutputUploadCompletedTimestamp + } + return nil +} + +func (x *ExecutedActionMetadata) GetAuxiliaryMetadata() []*anypb.Any { + if x != nil { + if x.xxx_hidden_AuxiliaryMetadata != nil { + return *x.xxx_hidden_AuxiliaryMetadata + } + } + return nil +} + +func (x *ExecutedActionMetadata) SetWorker(v string) { + x.xxx_hidden_Worker = v +} + +func (x *ExecutedActionMetadata) SetQueuedTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_QueuedTimestamp = v +} + +func (x *ExecutedActionMetadata) SetWorkerStartTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_WorkerStartTimestamp = v +} + +func (x *ExecutedActionMetadata) SetWorkerCompletedTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_WorkerCompletedTimestamp = v +} + +func (x *ExecutedActionMetadata) SetInputFetchStartTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_InputFetchStartTimestamp = v +} + +func (x *ExecutedActionMetadata) SetInputFetchCompletedTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_InputFetchCompletedTimestamp = v +} + +func (x *ExecutedActionMetadata) SetExecutionStartTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_ExecutionStartTimestamp = v +} + +func (x *ExecutedActionMetadata) SetExecutionCompletedTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_ExecutionCompletedTimestamp = v +} + +func (x *ExecutedActionMetadata) SetVirtualExecutionDuration(v *durationpb.Duration) { + x.xxx_hidden_VirtualExecutionDuration = v +} + +func (x *ExecutedActionMetadata) SetOutputUploadStartTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_OutputUploadStartTimestamp = v +} + +func (x *ExecutedActionMetadata) SetOutputUploadCompletedTimestamp(v *timestamppb.Timestamp) { + x.xxx_hidden_OutputUploadCompletedTimestamp = v +} + +func (x *ExecutedActionMetadata) SetAuxiliaryMetadata(v []*anypb.Any) { + x.xxx_hidden_AuxiliaryMetadata = &v +} + +func (x *ExecutedActionMetadata) HasQueuedTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_QueuedTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasWorkerStartTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_WorkerStartTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasWorkerCompletedTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_WorkerCompletedTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasInputFetchStartTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_InputFetchStartTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasInputFetchCompletedTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_InputFetchCompletedTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasExecutionStartTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExecutionStartTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasExecutionCompletedTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExecutionCompletedTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasVirtualExecutionDuration() bool { + if x == nil { + return false + } + return x.xxx_hidden_VirtualExecutionDuration != nil +} + +func (x *ExecutedActionMetadata) HasOutputUploadStartTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_OutputUploadStartTimestamp != nil +} + +func (x *ExecutedActionMetadata) HasOutputUploadCompletedTimestamp() bool { + if x == nil { + return false + } + return x.xxx_hidden_OutputUploadCompletedTimestamp != nil +} + +func (x *ExecutedActionMetadata) ClearQueuedTimestamp() { + x.xxx_hidden_QueuedTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearWorkerStartTimestamp() { + x.xxx_hidden_WorkerStartTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearWorkerCompletedTimestamp() { + x.xxx_hidden_WorkerCompletedTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearInputFetchStartTimestamp() { + x.xxx_hidden_InputFetchStartTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearInputFetchCompletedTimestamp() { + x.xxx_hidden_InputFetchCompletedTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearExecutionStartTimestamp() { + x.xxx_hidden_ExecutionStartTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearExecutionCompletedTimestamp() { + x.xxx_hidden_ExecutionCompletedTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearVirtualExecutionDuration() { + x.xxx_hidden_VirtualExecutionDuration = nil +} + +func (x *ExecutedActionMetadata) ClearOutputUploadStartTimestamp() { + x.xxx_hidden_OutputUploadStartTimestamp = nil +} + +func (x *ExecutedActionMetadata) ClearOutputUploadCompletedTimestamp() { + x.xxx_hidden_OutputUploadCompletedTimestamp = nil +} + +type ExecutedActionMetadata_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the worker which ran the execution. + Worker string + // When was the action added to the queue. + QueuedTimestamp *timestamppb.Timestamp + // When the worker received the action. + WorkerStartTimestamp *timestamppb.Timestamp + // When the worker completed the action, including all stages. + WorkerCompletedTimestamp *timestamppb.Timestamp + // When the worker started fetching action inputs. + InputFetchStartTimestamp *timestamppb.Timestamp + // When the worker finished fetching action inputs. + InputFetchCompletedTimestamp *timestamppb.Timestamp + // When the worker started executing the action command. + ExecutionStartTimestamp *timestamppb.Timestamp + // When the worker completed executing the action command. + ExecutionCompletedTimestamp *timestamppb.Timestamp + // New in v2.3: the amount of time the worker spent executing the action + // command, potentially computed using a worker-specific virtual clock. + // + // The virtual execution duration is only intended to cover the "execution" of + // the specified action and not time in queue nor any overheads before or + // after execution such as marshalling inputs/outputs. The server SHOULD avoid + // including time spent the client doesn't have control over, and MAY extend + // or reduce the execution duration to account for delays or speedups that + // occur during execution itself (e.g., lazily loading data from the Content + // Addressable Storage, live migration of virtual machines, emulation + // overhead). + // + // The method of timekeeping used to compute the virtual execution duration + // MUST be consistent with what is used to enforce the + // [Action][build.bazel.remote.execution.v2.Action]'s `timeout`. There is no + // relationship between the virtual execution duration and the values of + // `execution_start_timestamp` and `execution_completed_timestamp`. + VirtualExecutionDuration *durationpb.Duration + // When the worker started uploading action outputs. + OutputUploadStartTimestamp *timestamppb.Timestamp + // When the worker finished uploading action outputs. + OutputUploadCompletedTimestamp *timestamppb.Timestamp + // Details that are specific to the kind of worker used. For example, + // on POSIX-like systems this could contain a message with + // getrusage(2) statistics. + AuxiliaryMetadata []*anypb.Any +} + +func (b0 ExecutedActionMetadata_builder) Build() *ExecutedActionMetadata { + m0 := &ExecutedActionMetadata{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Worker = b.Worker + x.xxx_hidden_QueuedTimestamp = b.QueuedTimestamp + x.xxx_hidden_WorkerStartTimestamp = b.WorkerStartTimestamp + x.xxx_hidden_WorkerCompletedTimestamp = b.WorkerCompletedTimestamp + x.xxx_hidden_InputFetchStartTimestamp = b.InputFetchStartTimestamp + x.xxx_hidden_InputFetchCompletedTimestamp = b.InputFetchCompletedTimestamp + x.xxx_hidden_ExecutionStartTimestamp = b.ExecutionStartTimestamp + x.xxx_hidden_ExecutionCompletedTimestamp = b.ExecutionCompletedTimestamp + x.xxx_hidden_VirtualExecutionDuration = b.VirtualExecutionDuration + x.xxx_hidden_OutputUploadStartTimestamp = b.OutputUploadStartTimestamp + x.xxx_hidden_OutputUploadCompletedTimestamp = b.OutputUploadCompletedTimestamp + x.xxx_hidden_AuxiliaryMetadata = &b.AuxiliaryMetadata + return m0 +} + +// An ActionResult represents the result of an +// [Action][build.bazel.remote.execution.v2.Action] being run. +// +// It is advised that at least one field (for example +// `ActionResult.execution_metadata.Worker`) have a non-default value, to +// ensure that the serialized value is non-empty, which can then be used +// as a basic data sanity check. +type ActionResult struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_OutputFiles *[]*OutputFile `protobuf:"bytes,2,rep,name=output_files,json=outputFiles,proto3"` + xxx_hidden_OutputFileSymlinks *[]*OutputSymlink `protobuf:"bytes,10,rep,name=output_file_symlinks,json=outputFileSymlinks,proto3"` + xxx_hidden_OutputSymlinks *[]*OutputSymlink `protobuf:"bytes,12,rep,name=output_symlinks,json=outputSymlinks,proto3"` + xxx_hidden_OutputDirectories *[]*OutputDirectory `protobuf:"bytes,3,rep,name=output_directories,json=outputDirectories,proto3"` + xxx_hidden_OutputDirectorySymlinks *[]*OutputSymlink `protobuf:"bytes,11,rep,name=output_directory_symlinks,json=outputDirectorySymlinks,proto3"` + xxx_hidden_ExitCode int32 `protobuf:"varint,4,opt,name=exit_code,json=exitCode,proto3"` + xxx_hidden_StdoutRaw []byte `protobuf:"bytes,5,opt,name=stdout_raw,json=stdoutRaw,proto3"` + xxx_hidden_StdoutDigest *Digest `protobuf:"bytes,6,opt,name=stdout_digest,json=stdoutDigest,proto3"` + xxx_hidden_StderrRaw []byte `protobuf:"bytes,7,opt,name=stderr_raw,json=stderrRaw,proto3"` + xxx_hidden_StderrDigest *Digest `protobuf:"bytes,8,opt,name=stderr_digest,json=stderrDigest,proto3"` + xxx_hidden_ExecutionMetadata *ExecutedActionMetadata `protobuf:"bytes,9,opt,name=execution_metadata,json=executionMetadata,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ActionResult) Reset() { + *x = ActionResult{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ActionResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActionResult) ProtoMessage() {} + +func (x *ActionResult) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ActionResult) GetOutputFiles() []*OutputFile { + if x != nil { + if x.xxx_hidden_OutputFiles != nil { + return *x.xxx_hidden_OutputFiles + } + } + return nil +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *ActionResult) GetOutputFileSymlinks() []*OutputSymlink { + if x != nil { + if x.xxx_hidden_OutputFileSymlinks != nil { + return *x.xxx_hidden_OutputFileSymlinks + } + } + return nil +} + +func (x *ActionResult) GetOutputSymlinks() []*OutputSymlink { + if x != nil { + if x.xxx_hidden_OutputSymlinks != nil { + return *x.xxx_hidden_OutputSymlinks + } + } + return nil +} + +func (x *ActionResult) GetOutputDirectories() []*OutputDirectory { + if x != nil { + if x.xxx_hidden_OutputDirectories != nil { + return *x.xxx_hidden_OutputDirectories + } + } + return nil +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *ActionResult) GetOutputDirectorySymlinks() []*OutputSymlink { + if x != nil { + if x.xxx_hidden_OutputDirectorySymlinks != nil { + return *x.xxx_hidden_OutputDirectorySymlinks + } + } + return nil +} + +func (x *ActionResult) GetExitCode() int32 { + if x != nil { + return x.xxx_hidden_ExitCode + } + return 0 +} + +func (x *ActionResult) GetStdoutRaw() []byte { + if x != nil { + return x.xxx_hidden_StdoutRaw + } + return nil +} + +func (x *ActionResult) GetStdoutDigest() *Digest { + if x != nil { + return x.xxx_hidden_StdoutDigest + } + return nil +} + +func (x *ActionResult) GetStderrRaw() []byte { + if x != nil { + return x.xxx_hidden_StderrRaw + } + return nil +} + +func (x *ActionResult) GetStderrDigest() *Digest { + if x != nil { + return x.xxx_hidden_StderrDigest + } + return nil +} + +func (x *ActionResult) GetExecutionMetadata() *ExecutedActionMetadata { + if x != nil { + return x.xxx_hidden_ExecutionMetadata + } + return nil +} + +func (x *ActionResult) SetOutputFiles(v []*OutputFile) { + x.xxx_hidden_OutputFiles = &v +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *ActionResult) SetOutputFileSymlinks(v []*OutputSymlink) { + x.xxx_hidden_OutputFileSymlinks = &v +} + +func (x *ActionResult) SetOutputSymlinks(v []*OutputSymlink) { + x.xxx_hidden_OutputSymlinks = &v +} + +func (x *ActionResult) SetOutputDirectories(v []*OutputDirectory) { + x.xxx_hidden_OutputDirectories = &v +} + +// Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. +func (x *ActionResult) SetOutputDirectorySymlinks(v []*OutputSymlink) { + x.xxx_hidden_OutputDirectorySymlinks = &v +} + +func (x *ActionResult) SetExitCode(v int32) { + x.xxx_hidden_ExitCode = v +} + +func (x *ActionResult) SetStdoutRaw(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_StdoutRaw = v +} + +func (x *ActionResult) SetStdoutDigest(v *Digest) { + x.xxx_hidden_StdoutDigest = v +} + +func (x *ActionResult) SetStderrRaw(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_StderrRaw = v +} + +func (x *ActionResult) SetStderrDigest(v *Digest) { + x.xxx_hidden_StderrDigest = v +} + +func (x *ActionResult) SetExecutionMetadata(v *ExecutedActionMetadata) { + x.xxx_hidden_ExecutionMetadata = v +} + +func (x *ActionResult) HasStdoutDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_StdoutDigest != nil +} + +func (x *ActionResult) HasStderrDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_StderrDigest != nil +} + +func (x *ActionResult) HasExecutionMetadata() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExecutionMetadata != nil +} + +func (x *ActionResult) ClearStdoutDigest() { + x.xxx_hidden_StdoutDigest = nil +} + +func (x *ActionResult) ClearStderrDigest() { + x.xxx_hidden_StderrDigest = nil +} + +func (x *ActionResult) ClearExecutionMetadata() { + x.xxx_hidden_ExecutionMetadata = nil +} + +type ActionResult_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The output files of the action. For each output file requested in the + // `output_files` or `output_paths` field of the Action, if the corresponding + // file existed after the action completed, a single entry will be present + // either in this field, or the `output_file_symlinks` field if the file was + // a symbolic link to another file (`output_symlinks` field after v2.1). + // + // If an output listed in `output_files` was found, but was a directory rather + // than a regular file, the server will return a FAILED_PRECONDITION. + // If the action does not produce the requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + OutputFiles []*OutputFile + // The output files of the action that are symbolic links to other files. Those + // may be links to other output files, or input files, or even absolute paths + // outside of the working directory, if the server supports + // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. + // For each output file requested in the `output_files` or `output_paths` + // field of the Action, if the corresponding file existed after + // the action completed, a single entry will be present either in this field, + // or in the `output_files` field, if the file was not a symbolic link. + // + // If an output symbolic link of the same name as listed in `output_files` of + // the Command was found, but its target type was not a regular file, the + // server will return a FAILED_PRECONDITION. + // If the action does not produce the requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + // + // DEPRECATED as of v2.1. Servers that wish to be compatible with v2.0 API + // should still populate this field in addition to `output_symlinks`. + // + // Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. + OutputFileSymlinks []*OutputSymlink + // New in v2.1: this field will only be populated if the command + // `output_paths` field was used, and not the pre v2.1 `output_files` or + // `output_directories` fields. + // The output paths of the action that are symbolic links to other paths. Those + // may be links to other outputs, or inputs, or even absolute paths + // outside of the working directory, if the server supports + // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. + // A single entry for each output requested in `output_paths` + // field of the Action, if the corresponding path existed after + // the action completed and was a symbolic link. + // + // If the action does not produce a requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + OutputSymlinks []*OutputSymlink + // The output directories of the action. For each output directory requested + // in the `output_directories` or `output_paths` field of the Action, if the + // corresponding directory existed after the action completed, a single entry + // will be present in the output list, which will contain the digest of a + // [Tree][build.bazel.remote.execution.v2.Tree] message containing the + // directory tree, and the path equal exactly to the corresponding Action + // output_directories member. + // + // As an example, suppose the Action had an output directory `a/b/dir` and the + // execution produced the following contents in `a/b/dir`: a file named `bar` + // and a directory named `foo` with an executable file named `baz`. Then, + // output_directory will contain (hashes shortened for readability): + // + // ```json + // // OutputDirectory proto: + // + // { + // path: "a/b/dir" + // tree_digest: { + // hash: "4a73bc9d03...", + // size: 55 + // } + // } + // + // // Tree proto with hash "4a73bc9d03..." and size 55: + // + // { + // root: { + // files: [ + // { + // name: "bar", + // digest: { + // hash: "4a73bc9d03...", + // size: 65534 + // } + // } + // ], + // directories: [ + // { + // name: "foo", + // digest: { + // hash: "4cf2eda940...", + // size: 43 + // } + // } + // ] + // } + // children : { + // // (Directory proto with hash "4cf2eda940..." and size 43) + // files: [ + // { + // name: "baz", + // digest: { + // hash: "b2c941073e...", + // size: 1294, + // }, + // is_executable: true + // } + // ] + // } + // } + // + // ``` + // If an output of the same name as listed in `output_files` of + // the Command was found in `output_directories`, but was not a directory, the + // server will return a FAILED_PRECONDITION. + OutputDirectories []*OutputDirectory + // The output directories of the action that are symbolic links to other + // directories. Those may be links to other output directories, or input + // directories, or even absolute paths outside of the working directory, + // if the server supports + // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. + // For each output directory requested in the `output_directories` field of + // the Action, if the directory existed after the action completed, a + // single entry will be present either in this field, or in the + // `output_directories` field, if the directory was not a symbolic link. + // + // If an output of the same name was found, but was a symbolic link to a file + // instead of a directory, the server will return a FAILED_PRECONDITION. + // If the action does not produce the requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + // + // DEPRECATED as of v2.1. Servers that wish to be compatible with v2.0 API + // should still populate this field in addition to `output_symlinks`. + // + // Deprecated: Marked as deprecated in build/bazel/remote/execution/v2/remote_execution.proto. + OutputDirectorySymlinks []*OutputSymlink + // The exit code of the command. + ExitCode int32 + // The standard output buffer of the action. The server SHOULD NOT inline + // stdout unless requested by the client in the + // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] + // message. The server MAY omit inlining, even if requested, and MUST do so if inlining + // would cause the response to exceed message size limits. + // Clients SHOULD NOT populate this field when uploading to the cache. + StdoutRaw []byte + // The digest for a blob containing the standard output of the action, which + // can be retrieved from the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + StdoutDigest *Digest + // The standard error buffer of the action. The server SHOULD NOT inline + // stderr unless requested by the client in the + // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] + // message. The server MAY omit inlining, even if requested, and MUST do so if inlining + // would cause the response to exceed message size limits. + // Clients SHOULD NOT populate this field when uploading to the cache. + StderrRaw []byte + // The digest for a blob containing the standard error of the action, which + // can be retrieved from the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + StderrDigest *Digest + // The details of the execution that originally produced this result. + ExecutionMetadata *ExecutedActionMetadata +} + +func (b0 ActionResult_builder) Build() *ActionResult { + m0 := &ActionResult{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_OutputFiles = &b.OutputFiles + x.xxx_hidden_OutputFileSymlinks = &b.OutputFileSymlinks + x.xxx_hidden_OutputSymlinks = &b.OutputSymlinks + x.xxx_hidden_OutputDirectories = &b.OutputDirectories + x.xxx_hidden_OutputDirectorySymlinks = &b.OutputDirectorySymlinks + x.xxx_hidden_ExitCode = b.ExitCode + x.xxx_hidden_StdoutRaw = b.StdoutRaw + x.xxx_hidden_StdoutDigest = b.StdoutDigest + x.xxx_hidden_StderrRaw = b.StderrRaw + x.xxx_hidden_StderrDigest = b.StderrDigest + x.xxx_hidden_ExecutionMetadata = b.ExecutionMetadata + return m0 +} + +// An `OutputFile` is similar to a +// [FileNode][build.bazel.remote.execution.v2.FileNode], but it is used as an +// output in an `ActionResult`. It allows a full file path rather than +// only a name. +type OutputFile struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Path string `protobuf:"bytes,1,opt,name=path,proto3"` + xxx_hidden_Digest *Digest `protobuf:"bytes,2,opt,name=digest,proto3"` + xxx_hidden_IsExecutable bool `protobuf:"varint,4,opt,name=is_executable,json=isExecutable,proto3"` + xxx_hidden_Contents []byte `protobuf:"bytes,5,opt,name=contents,proto3"` + xxx_hidden_NodeProperties *NodeProperties `protobuf:"bytes,7,opt,name=node_properties,json=nodeProperties,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OutputFile) Reset() { + *x = OutputFile{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OutputFile) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OutputFile) ProtoMessage() {} + +func (x *OutputFile) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *OutputFile) GetPath() string { + if x != nil { + return x.xxx_hidden_Path + } + return "" +} + +func (x *OutputFile) GetDigest() *Digest { + if x != nil { + return x.xxx_hidden_Digest + } + return nil +} + +func (x *OutputFile) GetIsExecutable() bool { + if x != nil { + return x.xxx_hidden_IsExecutable + } + return false +} + +func (x *OutputFile) GetContents() []byte { + if x != nil { + return x.xxx_hidden_Contents + } + return nil +} + +func (x *OutputFile) GetNodeProperties() *NodeProperties { + if x != nil { + return x.xxx_hidden_NodeProperties + } + return nil +} + +func (x *OutputFile) SetPath(v string) { + x.xxx_hidden_Path = v +} + +func (x *OutputFile) SetDigest(v *Digest) { + x.xxx_hidden_Digest = v +} + +func (x *OutputFile) SetIsExecutable(v bool) { + x.xxx_hidden_IsExecutable = v +} + +func (x *OutputFile) SetContents(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_Contents = v +} + +func (x *OutputFile) SetNodeProperties(v *NodeProperties) { + x.xxx_hidden_NodeProperties = v +} + +func (x *OutputFile) HasDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_Digest != nil +} + +func (x *OutputFile) HasNodeProperties() bool { + if x == nil { + return false + } + return x.xxx_hidden_NodeProperties != nil +} + +func (x *OutputFile) ClearDigest() { + x.xxx_hidden_Digest = nil +} + +func (x *OutputFile) ClearNodeProperties() { + x.xxx_hidden_NodeProperties = nil +} + +type OutputFile_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The full path of the file relative to the working directory, including the + // filename. The path separator is a forward slash `/`. Since this is a + // relative path, it MUST NOT begin with a leading forward slash. + Path string + // The digest of the file's content. + Digest *Digest + // True if file is executable, false otherwise. + IsExecutable bool + // The contents of the file if inlining was requested. The server SHOULD NOT inline + // file contents unless requested by the client in the + // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] + // message. The server MAY omit inlining, even if requested, and MUST do so if inlining + // would cause the response to exceed message size limits. + // Clients SHOULD NOT populate this field when uploading to the cache. + Contents []byte + NodeProperties *NodeProperties +} + +func (b0 OutputFile_builder) Build() *OutputFile { + m0 := &OutputFile{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Path = b.Path + x.xxx_hidden_Digest = b.Digest + x.xxx_hidden_IsExecutable = b.IsExecutable + x.xxx_hidden_Contents = b.Contents + x.xxx_hidden_NodeProperties = b.NodeProperties + return m0 +} + +// A `Tree` contains all the +// [Directory][build.bazel.remote.execution.v2.Directory] protos in a +// single directory Merkle tree, compressed into one message. +type Tree struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Root *Directory `protobuf:"bytes,1,opt,name=root,proto3"` + xxx_hidden_Children *[]*Directory `protobuf:"bytes,2,rep,name=children,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Tree) Reset() { + *x = Tree{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Tree) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tree) ProtoMessage() {} + +func (x *Tree) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Tree) GetRoot() *Directory { + if x != nil { + return x.xxx_hidden_Root + } + return nil +} + +func (x *Tree) GetChildren() []*Directory { + if x != nil { + if x.xxx_hidden_Children != nil { + return *x.xxx_hidden_Children + } + } + return nil +} + +func (x *Tree) SetRoot(v *Directory) { + x.xxx_hidden_Root = v +} + +func (x *Tree) SetChildren(v []*Directory) { + x.xxx_hidden_Children = &v +} + +func (x *Tree) HasRoot() bool { + if x == nil { + return false + } + return x.xxx_hidden_Root != nil +} + +func (x *Tree) ClearRoot() { + x.xxx_hidden_Root = nil +} + +type Tree_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The root directory in the tree. + Root *Directory + // All the child directories: the directories referred to by the root and, + // recursively, all its children. In order to reconstruct the directory tree, + // the client must take the digests of each of the child directories and then + // build up a tree starting from the `root`. + // Servers SHOULD ensure that these are ordered consistently such that two + // actions producing equivalent output directories on the same server + // implementation also produce Tree messages with matching digests. + Children []*Directory +} + +func (b0 Tree_builder) Build() *Tree { + m0 := &Tree{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Root = b.Root + x.xxx_hidden_Children = &b.Children + return m0 +} + +// An `OutputDirectory` is the output in an `ActionResult` corresponding to a +// directory's full contents rather than a single file. +type OutputDirectory struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Path string `protobuf:"bytes,1,opt,name=path,proto3"` + xxx_hidden_TreeDigest *Digest `protobuf:"bytes,3,opt,name=tree_digest,json=treeDigest,proto3"` + xxx_hidden_IsTopologicallySorted bool `protobuf:"varint,4,opt,name=is_topologically_sorted,json=isTopologicallySorted,proto3"` + xxx_hidden_RootDirectoryDigest *Digest `protobuf:"bytes,5,opt,name=root_directory_digest,json=rootDirectoryDigest,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OutputDirectory) Reset() { + *x = OutputDirectory{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OutputDirectory) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OutputDirectory) ProtoMessage() {} + +func (x *OutputDirectory) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *OutputDirectory) GetPath() string { + if x != nil { + return x.xxx_hidden_Path + } + return "" +} + +func (x *OutputDirectory) GetTreeDigest() *Digest { + if x != nil { + return x.xxx_hidden_TreeDigest + } + return nil +} + +func (x *OutputDirectory) GetIsTopologicallySorted() bool { + if x != nil { + return x.xxx_hidden_IsTopologicallySorted + } + return false +} + +func (x *OutputDirectory) GetRootDirectoryDigest() *Digest { + if x != nil { + return x.xxx_hidden_RootDirectoryDigest + } + return nil +} + +func (x *OutputDirectory) SetPath(v string) { + x.xxx_hidden_Path = v +} + +func (x *OutputDirectory) SetTreeDigest(v *Digest) { + x.xxx_hidden_TreeDigest = v +} + +func (x *OutputDirectory) SetIsTopologicallySorted(v bool) { + x.xxx_hidden_IsTopologicallySorted = v +} + +func (x *OutputDirectory) SetRootDirectoryDigest(v *Digest) { + x.xxx_hidden_RootDirectoryDigest = v +} + +func (x *OutputDirectory) HasTreeDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_TreeDigest != nil +} + +func (x *OutputDirectory) HasRootDirectoryDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_RootDirectoryDigest != nil +} + +func (x *OutputDirectory) ClearTreeDigest() { + x.xxx_hidden_TreeDigest = nil +} + +func (x *OutputDirectory) ClearRootDirectoryDigest() { + x.xxx_hidden_RootDirectoryDigest = nil +} + +type OutputDirectory_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The full path of the directory relative to the working directory. The path + // separator is a forward slash `/`. Since this is a relative path, it MUST + // NOT begin with a leading forward slash. The empty string value is allowed, + // and it denotes the entire working directory. + Path string + // The digest of the encoded + // [Tree][build.bazel.remote.execution.v2.Tree] proto containing the + // directory's contents. + TreeDigest *Digest + // If set, consumers MAY make the following assumptions about the + // directories contained in the Tree, so that it may be + // instantiated on a local file system by scanning through it + // sequentially: + // + // - All directories with the same binary representation are stored + // exactly once. + // - All directories, apart from the root directory, are referenced by + // at least one parent directory. + // - Directories are stored in topological order, with parents being + // stored before the child. The root directory is thus the first to + // be stored. + // + // Additionally, the Tree MUST be encoded as a stream of records, + // where each record has the following format: + // + // - A tag byte, having one of the following two values: + // - (1 << 3) | 2 == 0x0a: First record (the root directory). + // - (2 << 3) | 2 == 0x12: Any subsequent records (child directories). + // - The size of the directory, encoded as a base 128 varint. + // - The contents of the directory, encoded as a binary serialized + // Protobuf message. + // + // This encoding is a subset of the Protobuf wire format of the Tree + // message. As it is only permitted to store data associated with + // field numbers 1 and 2, the tag MUST be encoded as a single byte. + // More details on the Protobuf wire format can be found here: + // https://developers.google.com/protocol-buffers/docs/encoding + // + // It is recommended that implementations using this feature construct + // Tree objects manually using the specification given above, as + // opposed to using a Protobuf library to marshal a full Tree message. + // As individual Directory messages already need to be marshaled to + // compute their digests, constructing the Tree object manually avoids + // redundant marshaling. + IsTopologicallySorted bool + // The digest of the encoded + // [Directory][build.bazel.remote.execution.v2.Directory] proto + // containing the contents of the directory's root. + // + // If both `tree_digest` and `root_directory_digest` are set, this + // field MUST match the digest of the root directory contained in the + // Tree message. + RootDirectoryDigest *Digest +} + +func (b0 OutputDirectory_builder) Build() *OutputDirectory { + m0 := &OutputDirectory{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Path = b.Path + x.xxx_hidden_TreeDigest = b.TreeDigest + x.xxx_hidden_IsTopologicallySorted = b.IsTopologicallySorted + x.xxx_hidden_RootDirectoryDigest = b.RootDirectoryDigest + return m0 +} + +// An `OutputSymlink` is similar to a +// [Symlink][build.bazel.remote.execution.v2.SymlinkNode], but it is used as an +// output in an `ActionResult`. +// +// `OutputSymlink` is binary-compatible with `SymlinkNode`. +type OutputSymlink struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Path string `protobuf:"bytes,1,opt,name=path,proto3"` + xxx_hidden_Target string `protobuf:"bytes,2,opt,name=target,proto3"` + xxx_hidden_NodeProperties *NodeProperties `protobuf:"bytes,4,opt,name=node_properties,json=nodeProperties,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OutputSymlink) Reset() { + *x = OutputSymlink{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OutputSymlink) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OutputSymlink) ProtoMessage() {} + +func (x *OutputSymlink) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *OutputSymlink) GetPath() string { + if x != nil { + return x.xxx_hidden_Path + } + return "" +} + +func (x *OutputSymlink) GetTarget() string { + if x != nil { + return x.xxx_hidden_Target + } + return "" +} + +func (x *OutputSymlink) GetNodeProperties() *NodeProperties { + if x != nil { + return x.xxx_hidden_NodeProperties + } + return nil +} + +func (x *OutputSymlink) SetPath(v string) { + x.xxx_hidden_Path = v +} + +func (x *OutputSymlink) SetTarget(v string) { + x.xxx_hidden_Target = v +} + +func (x *OutputSymlink) SetNodeProperties(v *NodeProperties) { + x.xxx_hidden_NodeProperties = v +} + +func (x *OutputSymlink) HasNodeProperties() bool { + if x == nil { + return false + } + return x.xxx_hidden_NodeProperties != nil +} + +func (x *OutputSymlink) ClearNodeProperties() { + x.xxx_hidden_NodeProperties = nil +} + +type OutputSymlink_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The full path of the symlink relative to the working directory, including the + // filename. The path separator is a forward slash `/`. Since this is a + // relative path, it MUST NOT begin with a leading forward slash. + Path string + // The target path of the symlink. The path separator is a forward slash `/`. + // The target path can be relative to the parent directory of the symlink or + // it can be an absolute path starting with `/`. Support for absolute paths + // can be checked using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] + // API. `..` components are allowed anywhere in the target path. + Target string + NodeProperties *NodeProperties +} + +func (b0 OutputSymlink_builder) Build() *OutputSymlink { + m0 := &OutputSymlink{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Path = b.Path + x.xxx_hidden_Target = b.Target + x.xxx_hidden_NodeProperties = b.NodeProperties + return m0 +} + +// An `ExecutionPolicy` can be used to control the scheduling of the action. +type ExecutionPolicy struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Priority int32 `protobuf:"varint,1,opt,name=priority,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPolicy) Reset() { + *x = ExecutionPolicy{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPolicy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPolicy) ProtoMessage() {} + +func (x *ExecutionPolicy) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ExecutionPolicy) GetPriority() int32 { + if x != nil { + return x.xxx_hidden_Priority + } + return 0 +} + +func (x *ExecutionPolicy) SetPriority(v int32) { + x.xxx_hidden_Priority = v +} + +type ExecutionPolicy_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The priority (relative importance) of this action. Generally, a lower value + // means that the action should be run sooner than actions having a greater + // priority value, but the interpretation of a given value is server- + // dependent. A priority of 0 means the *default* priority. Priorities may be + // positive or negative, and such actions should run later or sooner than + // actions having the default priority, respectively. The particular semantics + // of this field is up to the server. In particular, every server will have + // their own supported range of priorities, and will decide how these map into + // scheduling policy. + Priority int32 +} + +func (b0 ExecutionPolicy_builder) Build() *ExecutionPolicy { + m0 := &ExecutionPolicy{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Priority = b.Priority + return m0 +} + +// A `ResultsCachePolicy` is used for fine-grained control over how action +// outputs are stored in the CAS and Action Cache. +type ResultsCachePolicy struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Priority int32 `protobuf:"varint,1,opt,name=priority,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResultsCachePolicy) Reset() { + *x = ResultsCachePolicy{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResultsCachePolicy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResultsCachePolicy) ProtoMessage() {} + +func (x *ResultsCachePolicy) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ResultsCachePolicy) GetPriority() int32 { + if x != nil { + return x.xxx_hidden_Priority + } + return 0 +} + +func (x *ResultsCachePolicy) SetPriority(v int32) { + x.xxx_hidden_Priority = v +} + +type ResultsCachePolicy_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The priority (relative importance) of this content in the overall cache. + // Generally, a lower value means a longer retention time or other advantage, + // but the interpretation of a given value is server-dependent. A priority of + // 0 means a *default* value, decided by the server. + // + // The particular semantics of this field is up to the server. In particular, + // every server will have their own supported range of priorities, and will + // decide how these map into retention/eviction policy. + Priority int32 +} + +func (b0 ResultsCachePolicy_builder) Build() *ResultsCachePolicy { + m0 := &ResultsCachePolicy{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Priority = b.Priority + return m0 +} + +// A request message for +// [Execution.Execute][build.bazel.remote.execution.v2.Execution.Execute]. +type ExecuteRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_SkipCacheLookup bool `protobuf:"varint,3,opt,name=skip_cache_lookup,json=skipCacheLookup,proto3"` + xxx_hidden_ActionDigest *Digest `protobuf:"bytes,6,opt,name=action_digest,json=actionDigest,proto3"` + xxx_hidden_ExecutionPolicy *ExecutionPolicy `protobuf:"bytes,7,opt,name=execution_policy,json=executionPolicy,proto3"` + xxx_hidden_ResultsCachePolicy *ResultsCachePolicy `protobuf:"bytes,8,opt,name=results_cache_policy,json=resultsCachePolicy,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,9,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + xxx_hidden_InlineStdout bool `protobuf:"varint,10,opt,name=inline_stdout,json=inlineStdout,proto3"` + xxx_hidden_InlineStderr bool `protobuf:"varint,11,opt,name=inline_stderr,json=inlineStderr,proto3"` + xxx_hidden_InlineOutputFiles []string `protobuf:"bytes,12,rep,name=inline_output_files,json=inlineOutputFiles,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecuteRequest) Reset() { + *x = ExecuteRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecuteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecuteRequest) ProtoMessage() {} + +func (x *ExecuteRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ExecuteRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *ExecuteRequest) GetSkipCacheLookup() bool { + if x != nil { + return x.xxx_hidden_SkipCacheLookup + } + return false +} + +func (x *ExecuteRequest) GetActionDigest() *Digest { + if x != nil { + return x.xxx_hidden_ActionDigest + } + return nil +} + +func (x *ExecuteRequest) GetExecutionPolicy() *ExecutionPolicy { + if x != nil { + return x.xxx_hidden_ExecutionPolicy + } + return nil +} + +func (x *ExecuteRequest) GetResultsCachePolicy() *ResultsCachePolicy { + if x != nil { + return x.xxx_hidden_ResultsCachePolicy + } + return nil +} + +func (x *ExecuteRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *ExecuteRequest) GetInlineStdout() bool { + if x != nil { + return x.xxx_hidden_InlineStdout + } + return false +} + +func (x *ExecuteRequest) GetInlineStderr() bool { + if x != nil { + return x.xxx_hidden_InlineStderr + } + return false +} + +func (x *ExecuteRequest) GetInlineOutputFiles() []string { + if x != nil { + return x.xxx_hidden_InlineOutputFiles + } + return nil +} + +func (x *ExecuteRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *ExecuteRequest) SetSkipCacheLookup(v bool) { + x.xxx_hidden_SkipCacheLookup = v +} + +func (x *ExecuteRequest) SetActionDigest(v *Digest) { + x.xxx_hidden_ActionDigest = v +} + +func (x *ExecuteRequest) SetExecutionPolicy(v *ExecutionPolicy) { + x.xxx_hidden_ExecutionPolicy = v +} + +func (x *ExecuteRequest) SetResultsCachePolicy(v *ResultsCachePolicy) { + x.xxx_hidden_ResultsCachePolicy = v +} + +func (x *ExecuteRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *ExecuteRequest) SetInlineStdout(v bool) { + x.xxx_hidden_InlineStdout = v +} + +func (x *ExecuteRequest) SetInlineStderr(v bool) { + x.xxx_hidden_InlineStderr = v +} + +func (x *ExecuteRequest) SetInlineOutputFiles(v []string) { + x.xxx_hidden_InlineOutputFiles = v +} + +func (x *ExecuteRequest) HasActionDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_ActionDigest != nil +} + +func (x *ExecuteRequest) HasExecutionPolicy() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExecutionPolicy != nil +} + +func (x *ExecuteRequest) HasResultsCachePolicy() bool { + if x == nil { + return false + } + return x.xxx_hidden_ResultsCachePolicy != nil +} + +func (x *ExecuteRequest) ClearActionDigest() { + x.xxx_hidden_ActionDigest = nil +} + +func (x *ExecuteRequest) ClearExecutionPolicy() { + x.xxx_hidden_ExecutionPolicy = nil +} + +func (x *ExecuteRequest) ClearResultsCachePolicy() { + x.xxx_hidden_ResultsCachePolicy = nil +} + +type ExecuteRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // If true, the action will be executed even if its result is already + // present in the [ActionCache][build.bazel.remote.execution.v2.ActionCache]. + // The execution is still allowed to be merged with other in-flight executions + // of the same action, however - semantically, the service MUST only guarantee + // that the results of an execution with this field set were not visible + // before the corresponding execution request was sent. + // Note that actions from execution requests setting this field set are still + // eligible to be entered into the action cache upon completion, and services + // SHOULD overwrite any existing entries that may exist. This allows + // skip_cache_lookup requests to be used as a mechanism for replacing action + // cache entries that reference outputs no longer available or that are + // poisoned in any way. + // If false, the result may be served from the action cache. + SkipCacheLookup bool + // The digest of the [Action][build.bazel.remote.execution.v2.Action] to + // execute. + ActionDigest *Digest + // An optional policy for execution of the action. + // The server will have a default policy if this is not provided. + ExecutionPolicy *ExecutionPolicy + // An optional policy for the results of this execution in the remote cache. + // The server will have a default policy if this is not provided. + // This may be applied to both the ActionResult and the associated blobs. + ResultsCachePolicy *ResultsCachePolicy + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the action digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value + // A hint to the server to request inlining stdout in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + InlineStdout bool + // A hint to the server to request inlining stderr in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + InlineStderr bool + // A hint to the server to inline the contents of the listed output files. + // Each path needs to exactly match one file path in either `output_paths` or + // `output_files` (DEPRECATED since v2.1) in the + // [Command][build.bazel.remote.execution.v2.Command] message. + InlineOutputFiles []string +} + +func (b0 ExecuteRequest_builder) Build() *ExecuteRequest { + m0 := &ExecuteRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_SkipCacheLookup = b.SkipCacheLookup + x.xxx_hidden_ActionDigest = b.ActionDigest + x.xxx_hidden_ExecutionPolicy = b.ExecutionPolicy + x.xxx_hidden_ResultsCachePolicy = b.ResultsCachePolicy + x.xxx_hidden_DigestFunction = b.DigestFunction + x.xxx_hidden_InlineStdout = b.InlineStdout + x.xxx_hidden_InlineStderr = b.InlineStderr + x.xxx_hidden_InlineOutputFiles = b.InlineOutputFiles + return m0 +} + +// A `LogFile` is a log stored in the CAS. +type LogFile struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Digest *Digest `protobuf:"bytes,1,opt,name=digest,proto3"` + xxx_hidden_HumanReadable bool `protobuf:"varint,2,opt,name=human_readable,json=humanReadable,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogFile) Reset() { + *x = LogFile{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogFile) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogFile) ProtoMessage() {} + +func (x *LogFile) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *LogFile) GetDigest() *Digest { + if x != nil { + return x.xxx_hidden_Digest + } + return nil +} + +func (x *LogFile) GetHumanReadable() bool { + if x != nil { + return x.xxx_hidden_HumanReadable + } + return false +} + +func (x *LogFile) SetDigest(v *Digest) { + x.xxx_hidden_Digest = v +} + +func (x *LogFile) SetHumanReadable(v bool) { + x.xxx_hidden_HumanReadable = v +} + +func (x *LogFile) HasDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_Digest != nil +} + +func (x *LogFile) ClearDigest() { + x.xxx_hidden_Digest = nil +} + +type LogFile_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The digest of the log contents. + Digest *Digest + // This is a hint as to the purpose of the log, and is set to true if the log + // is human-readable text that can be usefully displayed to a user, and false + // otherwise. For instance, if a command-line client wishes to print the + // server logs to the terminal for a failed action, this allows it to avoid + // displaying a binary file. + HumanReadable bool +} + +func (b0 LogFile_builder) Build() *LogFile { + m0 := &LogFile{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Digest = b.Digest + x.xxx_hidden_HumanReadable = b.HumanReadable + return m0 +} + +// The response message for +// [Execution.Execute][build.bazel.remote.execution.v2.Execution.Execute], +// which will be contained in the [response +// field][google.longrunning.Operation.response] of the +// [Operation][google.longrunning.Operation]. +type ExecuteResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Result *ActionResult `protobuf:"bytes,1,opt,name=result,proto3"` + xxx_hidden_CachedResult bool `protobuf:"varint,2,opt,name=cached_result,json=cachedResult,proto3"` + xxx_hidden_Status *status.Status `protobuf:"bytes,3,opt,name=status,proto3"` + xxx_hidden_ServerLogs map[string]*LogFile `protobuf:"bytes,4,rep,name=server_logs,json=serverLogs,proto3" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + xxx_hidden_Message string `protobuf:"bytes,5,opt,name=message,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecuteResponse) Reset() { + *x = ExecuteResponse{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecuteResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecuteResponse) ProtoMessage() {} + +func (x *ExecuteResponse) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ExecuteResponse) GetResult() *ActionResult { + if x != nil { + return x.xxx_hidden_Result + } + return nil +} + +func (x *ExecuteResponse) GetCachedResult() bool { + if x != nil { + return x.xxx_hidden_CachedResult + } + return false +} + +func (x *ExecuteResponse) GetStatus() *status.Status { + if x != nil { + return x.xxx_hidden_Status + } + return nil +} + +func (x *ExecuteResponse) GetServerLogs() map[string]*LogFile { + if x != nil { + return x.xxx_hidden_ServerLogs + } + return nil +} + +func (x *ExecuteResponse) GetMessage() string { + if x != nil { + return x.xxx_hidden_Message + } + return "" +} + +func (x *ExecuteResponse) SetResult(v *ActionResult) { + x.xxx_hidden_Result = v +} + +func (x *ExecuteResponse) SetCachedResult(v bool) { + x.xxx_hidden_CachedResult = v +} + +func (x *ExecuteResponse) SetStatus(v *status.Status) { + x.xxx_hidden_Status = v +} + +func (x *ExecuteResponse) SetServerLogs(v map[string]*LogFile) { + x.xxx_hidden_ServerLogs = v +} + +func (x *ExecuteResponse) SetMessage(v string) { + x.xxx_hidden_Message = v +} + +func (x *ExecuteResponse) HasResult() bool { + if x == nil { + return false + } + return x.xxx_hidden_Result != nil +} + +func (x *ExecuteResponse) HasStatus() bool { + if x == nil { + return false + } + return x.xxx_hidden_Status != nil +} + +func (x *ExecuteResponse) ClearResult() { + x.xxx_hidden_Result = nil +} + +func (x *ExecuteResponse) ClearStatus() { + x.xxx_hidden_Status = nil +} + +type ExecuteResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The result of the action. + Result *ActionResult + // True if the result was served from cache, false if it was executed. + CachedResult bool + // If the status has a code other than `OK`, it indicates that the action did + // not finish execution. For example, if the operation times out during + // execution, the status will have a `DEADLINE_EXCEEDED` code. Servers MUST + // use this field for errors in execution, rather than the error field on the + // `Operation` object. + // + // If the status code is other than `OK`, then the result MUST NOT be cached. + // For an error status, the `result` field is optional; the server may + // populate the output-, stdout-, and stderr-related fields if it has any + // information available, such as the stdout and stderr of a timed-out action. + Status *status.Status + // An optional list of additional log outputs the server wishes to provide. A + // server can use this to return execution-specific logs however it wishes. + // This is intended primarily to make it easier for users to debug issues that + // may be outside of the actual job execution, such as by identifying the + // worker executing the action or by providing logs from the worker's setup + // phase. The keys SHOULD be human readable so that a client can display them + // to a user. + ServerLogs map[string]*LogFile + // Freeform informational message with details on the execution of the action + // that may be displayed to the user upon failure or when requested explicitly. + Message string +} + +func (b0 ExecuteResponse_builder) Build() *ExecuteResponse { + m0 := &ExecuteResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Result = b.Result + x.xxx_hidden_CachedResult = b.CachedResult + x.xxx_hidden_Status = b.Status + x.xxx_hidden_ServerLogs = b.ServerLogs + x.xxx_hidden_Message = b.Message + return m0 +} + +// The current stage of action execution. +// +// Even though these stages are numbered according to the order in which +// they generally occur, there is no requirement that the remote +// execution system reports events along this order. For example, an +// operation MAY transition from the EXECUTING stage back to QUEUED +// in case the hardware on which the operation executes fails. +// +// If and only if the remote execution system reports that an operation +// has reached the COMPLETED stage, it MUST set the [done +// field][google.longrunning.Operation.done] of the +// [Operation][google.longrunning.Operation] and terminate the stream. +type ExecutionStage struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionStage) Reset() { + *x = ExecutionStage{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionStage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionStage) ProtoMessage() {} + +func (x *ExecutionStage) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type ExecutionStage_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 ExecutionStage_builder) Build() *ExecutionStage { + m0 := &ExecutionStage{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +// Metadata about an ongoing +// [execution][build.bazel.remote.execution.v2.Execution.Execute], which +// will be contained in the [metadata +// field][google.longrunning.Operation.metadata] of the +// [Operation][google.longrunning.Operation]. +type ExecuteOperationMetadata struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Stage ExecutionStage_Value `protobuf:"varint,1,opt,name=stage,proto3,enum=build.bazel.remote.execution.v2.ExecutionStage_Value"` + xxx_hidden_ActionDigest *Digest `protobuf:"bytes,2,opt,name=action_digest,json=actionDigest,proto3"` + xxx_hidden_StdoutStreamName string `protobuf:"bytes,3,opt,name=stdout_stream_name,json=stdoutStreamName,proto3"` + xxx_hidden_StderrStreamName string `protobuf:"bytes,4,opt,name=stderr_stream_name,json=stderrStreamName,proto3"` + xxx_hidden_PartialExecutionMetadata *ExecutedActionMetadata `protobuf:"bytes,5,opt,name=partial_execution_metadata,json=partialExecutionMetadata,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,6,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecuteOperationMetadata) Reset() { + *x = ExecuteOperationMetadata{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecuteOperationMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecuteOperationMetadata) ProtoMessage() {} + +func (x *ExecuteOperationMetadata) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[22] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ExecuteOperationMetadata) GetStage() ExecutionStage_Value { + if x != nil { + return x.xxx_hidden_Stage + } + return ExecutionStage_UNKNOWN +} + +func (x *ExecuteOperationMetadata) GetActionDigest() *Digest { + if x != nil { + return x.xxx_hidden_ActionDigest + } + return nil +} + +func (x *ExecuteOperationMetadata) GetStdoutStreamName() string { + if x != nil { + return x.xxx_hidden_StdoutStreamName + } + return "" +} + +func (x *ExecuteOperationMetadata) GetStderrStreamName() string { + if x != nil { + return x.xxx_hidden_StderrStreamName + } + return "" +} + +func (x *ExecuteOperationMetadata) GetPartialExecutionMetadata() *ExecutedActionMetadata { + if x != nil { + return x.xxx_hidden_PartialExecutionMetadata + } + return nil +} + +func (x *ExecuteOperationMetadata) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *ExecuteOperationMetadata) SetStage(v ExecutionStage_Value) { + x.xxx_hidden_Stage = v +} + +func (x *ExecuteOperationMetadata) SetActionDigest(v *Digest) { + x.xxx_hidden_ActionDigest = v +} + +func (x *ExecuteOperationMetadata) SetStdoutStreamName(v string) { + x.xxx_hidden_StdoutStreamName = v +} + +func (x *ExecuteOperationMetadata) SetStderrStreamName(v string) { + x.xxx_hidden_StderrStreamName = v +} + +func (x *ExecuteOperationMetadata) SetPartialExecutionMetadata(v *ExecutedActionMetadata) { + x.xxx_hidden_PartialExecutionMetadata = v +} + +func (x *ExecuteOperationMetadata) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *ExecuteOperationMetadata) HasActionDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_ActionDigest != nil +} + +func (x *ExecuteOperationMetadata) HasPartialExecutionMetadata() bool { + if x == nil { + return false + } + return x.xxx_hidden_PartialExecutionMetadata != nil +} + +func (x *ExecuteOperationMetadata) ClearActionDigest() { + x.xxx_hidden_ActionDigest = nil +} + +func (x *ExecuteOperationMetadata) ClearPartialExecutionMetadata() { + x.xxx_hidden_PartialExecutionMetadata = nil +} + +type ExecuteOperationMetadata_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The current stage of execution. + Stage ExecutionStage_Value + // The digest of the [Action][build.bazel.remote.execution.v2.Action] + // being executed. + ActionDigest *Digest + // If set, the client can use this resource name with + // [ByteStream.Read][google.bytestream.ByteStream.Read] to stream the + // standard output from the endpoint hosting streamed responses. + StdoutStreamName string + // If set, the client can use this resource name with + // [ByteStream.Read][google.bytestream.ByteStream.Read] to stream the + // standard error from the endpoint hosting streamed responses. + StderrStreamName string + // The client can read this field to view details about the ongoing + // execution. + PartialExecutionMetadata *ExecutedActionMetadata + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of BLAKE3, MD5, MURMUR3, SHA1, + // SHA256, SHA256TREE, SHA384, SHA512, or VSO, the server MAY leave + // this field unset. In that case the client SHOULD infer the digest + // function using the length of the action digest hash and the digest + // functions announced in the server's capabilities. + DigestFunction DigestFunction_Value +} + +func (b0 ExecuteOperationMetadata_builder) Build() *ExecuteOperationMetadata { + m0 := &ExecuteOperationMetadata{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Stage = b.Stage + x.xxx_hidden_ActionDigest = b.ActionDigest + x.xxx_hidden_StdoutStreamName = b.StdoutStreamName + x.xxx_hidden_StderrStreamName = b.StderrStreamName + x.xxx_hidden_PartialExecutionMetadata = b.PartialExecutionMetadata + x.xxx_hidden_DigestFunction = b.DigestFunction + return m0 +} + +// A request message for +// [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution]. +type WaitExecutionRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WaitExecutionRequest) Reset() { + *x = WaitExecutionRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WaitExecutionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WaitExecutionRequest) ProtoMessage() {} + +func (x *WaitExecutionRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *WaitExecutionRequest) GetName() string { + if x != nil { + return x.xxx_hidden_Name + } + return "" +} + +func (x *WaitExecutionRequest) SetName(v string) { + x.xxx_hidden_Name = v +} + +type WaitExecutionRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the [Operation][google.longrunning.Operation] + // returned by [Execute][build.bazel.remote.execution.v2.Execution.Execute]. + Name string +} + +func (b0 WaitExecutionRequest_builder) Build() *WaitExecutionRequest { + m0 := &WaitExecutionRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + return m0 +} + +// A request message for +// [ActionCache.GetActionResult][build.bazel.remote.execution.v2.ActionCache.GetActionResult]. +type GetActionResultRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_ActionDigest *Digest `protobuf:"bytes,2,opt,name=action_digest,json=actionDigest,proto3"` + xxx_hidden_InlineStdout bool `protobuf:"varint,3,opt,name=inline_stdout,json=inlineStdout,proto3"` + xxx_hidden_InlineStderr bool `protobuf:"varint,4,opt,name=inline_stderr,json=inlineStderr,proto3"` + xxx_hidden_InlineOutputFiles []string `protobuf:"bytes,5,rep,name=inline_output_files,json=inlineOutputFiles,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,6,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetActionResultRequest) Reset() { + *x = GetActionResultRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetActionResultRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetActionResultRequest) ProtoMessage() {} + +func (x *GetActionResultRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetActionResultRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *GetActionResultRequest) GetActionDigest() *Digest { + if x != nil { + return x.xxx_hidden_ActionDigest + } + return nil +} + +func (x *GetActionResultRequest) GetInlineStdout() bool { + if x != nil { + return x.xxx_hidden_InlineStdout + } + return false +} + +func (x *GetActionResultRequest) GetInlineStderr() bool { + if x != nil { + return x.xxx_hidden_InlineStderr + } + return false +} + +func (x *GetActionResultRequest) GetInlineOutputFiles() []string { + if x != nil { + return x.xxx_hidden_InlineOutputFiles + } + return nil +} + +func (x *GetActionResultRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *GetActionResultRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *GetActionResultRequest) SetActionDigest(v *Digest) { + x.xxx_hidden_ActionDigest = v +} + +func (x *GetActionResultRequest) SetInlineStdout(v bool) { + x.xxx_hidden_InlineStdout = v +} + +func (x *GetActionResultRequest) SetInlineStderr(v bool) { + x.xxx_hidden_InlineStderr = v +} + +func (x *GetActionResultRequest) SetInlineOutputFiles(v []string) { + x.xxx_hidden_InlineOutputFiles = v +} + +func (x *GetActionResultRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *GetActionResultRequest) HasActionDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_ActionDigest != nil +} + +func (x *GetActionResultRequest) ClearActionDigest() { + x.xxx_hidden_ActionDigest = nil +} + +type GetActionResultRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // The digest of the [Action][build.bazel.remote.execution.v2.Action] + // whose result is requested. + ActionDigest *Digest + // A hint to the server to request inlining stdout in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + InlineStdout bool + // A hint to the server to request inlining stderr in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + InlineStderr bool + // A hint to the server to inline the contents of the listed output files. + // Each path needs to exactly match one file path in either `output_paths` or + // `output_files` (DEPRECATED since v2.1) in the + // [Command][build.bazel.remote.execution.v2.Command] message. + InlineOutputFiles []string + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the action digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value +} + +func (b0 GetActionResultRequest_builder) Build() *GetActionResultRequest { + m0 := &GetActionResultRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_ActionDigest = b.ActionDigest + x.xxx_hidden_InlineStdout = b.InlineStdout + x.xxx_hidden_InlineStderr = b.InlineStderr + x.xxx_hidden_InlineOutputFiles = b.InlineOutputFiles + x.xxx_hidden_DigestFunction = b.DigestFunction + return m0 +} + +// A request message for +// [ActionCache.UpdateActionResult][build.bazel.remote.execution.v2.ActionCache.UpdateActionResult]. +type UpdateActionResultRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_ActionDigest *Digest `protobuf:"bytes,2,opt,name=action_digest,json=actionDigest,proto3"` + xxx_hidden_ActionResult *ActionResult `protobuf:"bytes,3,opt,name=action_result,json=actionResult,proto3"` + xxx_hidden_ResultsCachePolicy *ResultsCachePolicy `protobuf:"bytes,4,opt,name=results_cache_policy,json=resultsCachePolicy,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,5,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateActionResultRequest) Reset() { + *x = UpdateActionResultRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateActionResultRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateActionResultRequest) ProtoMessage() {} + +func (x *UpdateActionResultRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[25] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *UpdateActionResultRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *UpdateActionResultRequest) GetActionDigest() *Digest { + if x != nil { + return x.xxx_hidden_ActionDigest + } + return nil +} + +func (x *UpdateActionResultRequest) GetActionResult() *ActionResult { + if x != nil { + return x.xxx_hidden_ActionResult + } + return nil +} + +func (x *UpdateActionResultRequest) GetResultsCachePolicy() *ResultsCachePolicy { + if x != nil { + return x.xxx_hidden_ResultsCachePolicy + } + return nil +} + +func (x *UpdateActionResultRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *UpdateActionResultRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *UpdateActionResultRequest) SetActionDigest(v *Digest) { + x.xxx_hidden_ActionDigest = v +} + +func (x *UpdateActionResultRequest) SetActionResult(v *ActionResult) { + x.xxx_hidden_ActionResult = v +} + +func (x *UpdateActionResultRequest) SetResultsCachePolicy(v *ResultsCachePolicy) { + x.xxx_hidden_ResultsCachePolicy = v +} + +func (x *UpdateActionResultRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *UpdateActionResultRequest) HasActionDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_ActionDigest != nil +} + +func (x *UpdateActionResultRequest) HasActionResult() bool { + if x == nil { + return false + } + return x.xxx_hidden_ActionResult != nil +} + +func (x *UpdateActionResultRequest) HasResultsCachePolicy() bool { + if x == nil { + return false + } + return x.xxx_hidden_ResultsCachePolicy != nil +} + +func (x *UpdateActionResultRequest) ClearActionDigest() { + x.xxx_hidden_ActionDigest = nil +} + +func (x *UpdateActionResultRequest) ClearActionResult() { + x.xxx_hidden_ActionResult = nil +} + +func (x *UpdateActionResultRequest) ClearResultsCachePolicy() { + x.xxx_hidden_ResultsCachePolicy = nil +} + +type UpdateActionResultRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // The digest of the [Action][build.bazel.remote.execution.v2.Action] + // whose result is being uploaded. + ActionDigest *Digest + // The [ActionResult][build.bazel.remote.execution.v2.ActionResult] + // to store in the cache. + ActionResult *ActionResult + // An optional policy for the results of this execution in the remote cache. + // The server will have a default policy if this is not provided. + // This may be applied to both the ActionResult and the associated blobs. + ResultsCachePolicy *ResultsCachePolicy + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the action digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value +} + +func (b0 UpdateActionResultRequest_builder) Build() *UpdateActionResultRequest { + m0 := &UpdateActionResultRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_ActionDigest = b.ActionDigest + x.xxx_hidden_ActionResult = b.ActionResult + x.xxx_hidden_ResultsCachePolicy = b.ResultsCachePolicy + x.xxx_hidden_DigestFunction = b.DigestFunction + return m0 +} + +// A request message for +// [ContentAddressableStorage.FindMissingBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs]. +type FindMissingBlobsRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_BlobDigests *[]*Digest `protobuf:"bytes,2,rep,name=blob_digests,json=blobDigests,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,3,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *FindMissingBlobsRequest) Reset() { + *x = FindMissingBlobsRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FindMissingBlobsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindMissingBlobsRequest) ProtoMessage() {} + +func (x *FindMissingBlobsRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *FindMissingBlobsRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *FindMissingBlobsRequest) GetBlobDigests() []*Digest { + if x != nil { + if x.xxx_hidden_BlobDigests != nil { + return *x.xxx_hidden_BlobDigests + } + } + return nil +} + +func (x *FindMissingBlobsRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *FindMissingBlobsRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *FindMissingBlobsRequest) SetBlobDigests(v []*Digest) { + x.xxx_hidden_BlobDigests = &v +} + +func (x *FindMissingBlobsRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +type FindMissingBlobsRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // A list of the blobs to check. All digests MUST use the same digest + // function. + BlobDigests []*Digest + // The digest function of the blobs whose existence is checked. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value +} + +func (b0 FindMissingBlobsRequest_builder) Build() *FindMissingBlobsRequest { + m0 := &FindMissingBlobsRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_BlobDigests = &b.BlobDigests + x.xxx_hidden_DigestFunction = b.DigestFunction + return m0 +} + +// A response message for +// [ContentAddressableStorage.FindMissingBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs]. +type FindMissingBlobsResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_MissingBlobDigests *[]*Digest `protobuf:"bytes,2,rep,name=missing_blob_digests,json=missingBlobDigests,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *FindMissingBlobsResponse) Reset() { + *x = FindMissingBlobsResponse{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FindMissingBlobsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindMissingBlobsResponse) ProtoMessage() {} + +func (x *FindMissingBlobsResponse) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *FindMissingBlobsResponse) GetMissingBlobDigests() []*Digest { + if x != nil { + if x.xxx_hidden_MissingBlobDigests != nil { + return *x.xxx_hidden_MissingBlobDigests + } + } + return nil +} + +func (x *FindMissingBlobsResponse) SetMissingBlobDigests(v []*Digest) { + x.xxx_hidden_MissingBlobDigests = &v +} + +type FindMissingBlobsResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // A list of the blobs requested *not* present in the storage. + MissingBlobDigests []*Digest +} + +func (b0 FindMissingBlobsResponse_builder) Build() *FindMissingBlobsResponse { + m0 := &FindMissingBlobsResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_MissingBlobDigests = &b.MissingBlobDigests + return m0 +} + +// A request message for +// [ContentAddressableStorage.BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +type BatchUpdateBlobsRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_Requests *[]*BatchUpdateBlobsRequest_Request `protobuf:"bytes,2,rep,name=requests,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,5,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BatchUpdateBlobsRequest) Reset() { + *x = BatchUpdateBlobsRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BatchUpdateBlobsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchUpdateBlobsRequest) ProtoMessage() {} + +func (x *BatchUpdateBlobsRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[28] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *BatchUpdateBlobsRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *BatchUpdateBlobsRequest) GetRequests() []*BatchUpdateBlobsRequest_Request { + if x != nil { + if x.xxx_hidden_Requests != nil { + return *x.xxx_hidden_Requests + } + } + return nil +} + +func (x *BatchUpdateBlobsRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *BatchUpdateBlobsRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *BatchUpdateBlobsRequest) SetRequests(v []*BatchUpdateBlobsRequest_Request) { + x.xxx_hidden_Requests = &v +} + +func (x *BatchUpdateBlobsRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +type BatchUpdateBlobsRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // The individual upload requests. + Requests []*BatchUpdateBlobsRequest_Request + // The digest function that was used to compute the digests of the + // blobs being uploaded. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value +} + +func (b0 BatchUpdateBlobsRequest_builder) Build() *BatchUpdateBlobsRequest { + m0 := &BatchUpdateBlobsRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_Requests = &b.Requests + x.xxx_hidden_DigestFunction = b.DigestFunction + return m0 +} + +// A response message for +// [ContentAddressableStorage.BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +type BatchUpdateBlobsResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Responses *[]*BatchUpdateBlobsResponse_Response `protobuf:"bytes,1,rep,name=responses,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BatchUpdateBlobsResponse) Reset() { + *x = BatchUpdateBlobsResponse{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BatchUpdateBlobsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchUpdateBlobsResponse) ProtoMessage() {} + +func (x *BatchUpdateBlobsResponse) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[29] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *BatchUpdateBlobsResponse) GetResponses() []*BatchUpdateBlobsResponse_Response { + if x != nil { + if x.xxx_hidden_Responses != nil { + return *x.xxx_hidden_Responses + } + } + return nil +} + +func (x *BatchUpdateBlobsResponse) SetResponses(v []*BatchUpdateBlobsResponse_Response) { + x.xxx_hidden_Responses = &v +} + +type BatchUpdateBlobsResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The responses to the requests. + Responses []*BatchUpdateBlobsResponse_Response +} + +func (b0 BatchUpdateBlobsResponse_builder) Build() *BatchUpdateBlobsResponse { + m0 := &BatchUpdateBlobsResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Responses = &b.Responses + return m0 +} + +// A request message for +// [ContentAddressableStorage.BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. +type BatchReadBlobsRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_Digests *[]*Digest `protobuf:"bytes,2,rep,name=digests,proto3"` + xxx_hidden_AcceptableCompressors []Compressor_Value `protobuf:"varint,3,rep,packed,name=acceptable_compressors,json=acceptableCompressors,proto3,enum=build.bazel.remote.execution.v2.Compressor_Value"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,4,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BatchReadBlobsRequest) Reset() { + *x = BatchReadBlobsRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BatchReadBlobsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchReadBlobsRequest) ProtoMessage() {} + +func (x *BatchReadBlobsRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[30] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *BatchReadBlobsRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *BatchReadBlobsRequest) GetDigests() []*Digest { + if x != nil { + if x.xxx_hidden_Digests != nil { + return *x.xxx_hidden_Digests + } + } + return nil +} + +func (x *BatchReadBlobsRequest) GetAcceptableCompressors() []Compressor_Value { + if x != nil { + return x.xxx_hidden_AcceptableCompressors + } + return nil +} + +func (x *BatchReadBlobsRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *BatchReadBlobsRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *BatchReadBlobsRequest) SetDigests(v []*Digest) { + x.xxx_hidden_Digests = &v +} + +func (x *BatchReadBlobsRequest) SetAcceptableCompressors(v []Compressor_Value) { + x.xxx_hidden_AcceptableCompressors = v +} + +func (x *BatchReadBlobsRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +type BatchReadBlobsRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // The individual blob digests. All digests MUST use the same digest + // function. + Digests []*Digest + // A list of acceptable encodings for the returned inlined data, in no + // particular order. `IDENTITY` is always allowed even if not specified here. + AcceptableCompressors []Compressor_Value + // The digest function of the blobs being requested. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value +} + +func (b0 BatchReadBlobsRequest_builder) Build() *BatchReadBlobsRequest { + m0 := &BatchReadBlobsRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_Digests = &b.Digests + x.xxx_hidden_AcceptableCompressors = b.AcceptableCompressors + x.xxx_hidden_DigestFunction = b.DigestFunction + return m0 +} + +// A response message for +// [ContentAddressableStorage.BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. +type BatchReadBlobsResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Responses *[]*BatchReadBlobsResponse_Response `protobuf:"bytes,1,rep,name=responses,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BatchReadBlobsResponse) Reset() { + *x = BatchReadBlobsResponse{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BatchReadBlobsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchReadBlobsResponse) ProtoMessage() {} + +func (x *BatchReadBlobsResponse) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[31] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *BatchReadBlobsResponse) GetResponses() []*BatchReadBlobsResponse_Response { + if x != nil { + if x.xxx_hidden_Responses != nil { + return *x.xxx_hidden_Responses + } + } + return nil +} + +func (x *BatchReadBlobsResponse) SetResponses(v []*BatchReadBlobsResponse_Response) { + x.xxx_hidden_Responses = &v +} + +type BatchReadBlobsResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The responses to the requests. + Responses []*BatchReadBlobsResponse_Response +} + +func (b0 BatchReadBlobsResponse_builder) Build() *BatchReadBlobsResponse { + m0 := &BatchReadBlobsResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Responses = &b.Responses + return m0 +} + +// A request message for +// [ContentAddressableStorage.GetTree][build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree]. +type GetTreeRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_RootDigest *Digest `protobuf:"bytes,2,opt,name=root_digest,json=rootDigest,proto3"` + xxx_hidden_PageSize int32 `protobuf:"varint,3,opt,name=page_size,json=pageSize,proto3"` + xxx_hidden_PageToken string `protobuf:"bytes,4,opt,name=page_token,json=pageToken,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,5,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTreeRequest) Reset() { + *x = GetTreeRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTreeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTreeRequest) ProtoMessage() {} + +func (x *GetTreeRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[32] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetTreeRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *GetTreeRequest) GetRootDigest() *Digest { + if x != nil { + return x.xxx_hidden_RootDigest + } + return nil +} + +func (x *GetTreeRequest) GetPageSize() int32 { + if x != nil { + return x.xxx_hidden_PageSize + } + return 0 +} + +func (x *GetTreeRequest) GetPageToken() string { + if x != nil { + return x.xxx_hidden_PageToken + } + return "" +} + +func (x *GetTreeRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *GetTreeRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *GetTreeRequest) SetRootDigest(v *Digest) { + x.xxx_hidden_RootDigest = v +} + +func (x *GetTreeRequest) SetPageSize(v int32) { + x.xxx_hidden_PageSize = v +} + +func (x *GetTreeRequest) SetPageToken(v string) { + x.xxx_hidden_PageToken = v +} + +func (x *GetTreeRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *GetTreeRequest) HasRootDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_RootDigest != nil +} + +func (x *GetTreeRequest) ClearRootDigest() { + x.xxx_hidden_RootDigest = nil +} + +type GetTreeRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // The digest of the root, which must be an encoded + // [Directory][build.bazel.remote.execution.v2.Directory] message + // stored in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + RootDigest *Digest + // A maximum page size to request. If present, the server will request no more + // than this many items. Regardless of whether a page size is specified, the + // server may place its own limit on the number of items to be returned and + // require the client to retrieve more items using a subsequent request. + PageSize int32 + // A page token, which must be a value received in a previous + // [GetTreeResponse][build.bazel.remote.execution.v2.GetTreeResponse]. + // If present, the server will use that token as an offset, returning only + // that page and the ones that succeed it. + PageToken string + // The digest function that was used to compute the digest of the root + // directory. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the root digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value +} + +func (b0 GetTreeRequest_builder) Build() *GetTreeRequest { + m0 := &GetTreeRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_RootDigest = b.RootDigest + x.xxx_hidden_PageSize = b.PageSize + x.xxx_hidden_PageToken = b.PageToken + x.xxx_hidden_DigestFunction = b.DigestFunction + return m0 +} + +// A response message for +// [ContentAddressableStorage.GetTree][build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree]. +type GetTreeResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Directories *[]*Directory `protobuf:"bytes,1,rep,name=directories,proto3"` + xxx_hidden_NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTreeResponse) Reset() { + *x = GetTreeResponse{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTreeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTreeResponse) ProtoMessage() {} + +func (x *GetTreeResponse) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[33] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetTreeResponse) GetDirectories() []*Directory { + if x != nil { + if x.xxx_hidden_Directories != nil { + return *x.xxx_hidden_Directories + } + } + return nil +} + +func (x *GetTreeResponse) GetNextPageToken() string { + if x != nil { + return x.xxx_hidden_NextPageToken + } + return "" +} + +func (x *GetTreeResponse) SetDirectories(v []*Directory) { + x.xxx_hidden_Directories = &v +} + +func (x *GetTreeResponse) SetNextPageToken(v string) { + x.xxx_hidden_NextPageToken = v +} + +type GetTreeResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The directories descended from the requested root. + Directories []*Directory + // If present, signifies that there are more results which the client can + // retrieve by passing this as the page_token in a subsequent + // [request][build.bazel.remote.execution.v2.GetTreeRequest]. + // If empty, signifies that this is the last page of results. + NextPageToken string +} + +func (b0 GetTreeResponse_builder) Build() *GetTreeResponse { + m0 := &GetTreeResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Directories = &b.Directories + x.xxx_hidden_NextPageToken = b.NextPageToken + return m0 +} + +// A request message for +// [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob]. +type SplitBlobRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_BlobDigest *Digest `protobuf:"bytes,2,opt,name=blob_digest,json=blobDigest,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,3,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + xxx_hidden_ChunkingFunction ChunkingFunction_Value `protobuf:"varint,4,opt,name=chunking_function,json=chunkingFunction,proto3,enum=build.bazel.remote.execution.v2.ChunkingFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SplitBlobRequest) Reset() { + *x = SplitBlobRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SplitBlobRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SplitBlobRequest) ProtoMessage() {} + +func (x *SplitBlobRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[34] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SplitBlobRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *SplitBlobRequest) GetBlobDigest() *Digest { + if x != nil { + return x.xxx_hidden_BlobDigest + } + return nil +} + +func (x *SplitBlobRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *SplitBlobRequest) GetChunkingFunction() ChunkingFunction_Value { + if x != nil { + return x.xxx_hidden_ChunkingFunction + } + return ChunkingFunction_UNKNOWN +} + +func (x *SplitBlobRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *SplitBlobRequest) SetBlobDigest(v *Digest) { + x.xxx_hidden_BlobDigest = v +} + +func (x *SplitBlobRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *SplitBlobRequest) SetChunkingFunction(v ChunkingFunction_Value) { + x.xxx_hidden_ChunkingFunction = v +} + +func (x *SplitBlobRequest) HasBlobDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_BlobDigest != nil +} + +func (x *SplitBlobRequest) ClearBlobDigest() { + x.xxx_hidden_BlobDigest = nil +} + +type SplitBlobRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // The digest of the blob to be split. + BlobDigest *Digest + // The digest function of the blob to be split. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction DigestFunction_Value + // The chunking function that the client prefers to use. + // + // The server MAY use a different chunking function. + ChunkingFunction ChunkingFunction_Value +} + +func (b0 SplitBlobRequest_builder) Build() *SplitBlobRequest { + m0 := &SplitBlobRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_BlobDigest = b.BlobDigest + x.xxx_hidden_DigestFunction = b.DigestFunction + x.xxx_hidden_ChunkingFunction = b.ChunkingFunction + return m0 +} + +// A response message for +// [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob]. +type SplitBlobResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_ChunkDigests *[]*Digest `protobuf:"bytes,1,rep,name=chunk_digests,json=chunkDigests,proto3"` + xxx_hidden_ChunkingFunction ChunkingFunction_Value `protobuf:"varint,2,opt,name=chunking_function,json=chunkingFunction,proto3,enum=build.bazel.remote.execution.v2.ChunkingFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SplitBlobResponse) Reset() { + *x = SplitBlobResponse{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SplitBlobResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SplitBlobResponse) ProtoMessage() {} + +func (x *SplitBlobResponse) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[35] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SplitBlobResponse) GetChunkDigests() []*Digest { + if x != nil { + if x.xxx_hidden_ChunkDigests != nil { + return *x.xxx_hidden_ChunkDigests + } + } + return nil +} + +func (x *SplitBlobResponse) GetChunkingFunction() ChunkingFunction_Value { + if x != nil { + return x.xxx_hidden_ChunkingFunction + } + return ChunkingFunction_UNKNOWN +} + +func (x *SplitBlobResponse) SetChunkDigests(v []*Digest) { + x.xxx_hidden_ChunkDigests = &v +} + +func (x *SplitBlobResponse) SetChunkingFunction(v ChunkingFunction_Value) { + x.xxx_hidden_ChunkingFunction = v +} + +type SplitBlobResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The ordered list of digests of the chunks into which the blob was split. + // The original blob is assembled by concatenating the chunk data according to + // the order of the digests given by this list. + // + // The server MUST use the same digest function as the one explicitly or + // implicitly (through hash length) specified in the split request. + ChunkDigests []*Digest + // The chunking function used to split the blob. + ChunkingFunction ChunkingFunction_Value +} + +func (b0 SplitBlobResponse_builder) Build() *SplitBlobResponse { + m0 := &SplitBlobResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_ChunkDigests = &b.ChunkDigests + x.xxx_hidden_ChunkingFunction = b.ChunkingFunction + return m0 +} + +// A request message for +// [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob]. +type SpliceBlobRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + xxx_hidden_BlobDigest *Digest `protobuf:"bytes,2,opt,name=blob_digest,json=blobDigest,proto3"` + xxx_hidden_ChunkDigests *[]*Digest `protobuf:"bytes,3,rep,name=chunk_digests,json=chunkDigests,proto3"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,4,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + xxx_hidden_ChunkingFunction ChunkingFunction_Value `protobuf:"varint,5,opt,name=chunking_function,json=chunkingFunction,proto3,enum=build.bazel.remote.execution.v2.ChunkingFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SpliceBlobRequest) Reset() { + *x = SpliceBlobRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SpliceBlobRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SpliceBlobRequest) ProtoMessage() {} + +func (x *SpliceBlobRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[36] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SpliceBlobRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *SpliceBlobRequest) GetBlobDigest() *Digest { + if x != nil { + return x.xxx_hidden_BlobDigest + } + return nil +} + +func (x *SpliceBlobRequest) GetChunkDigests() []*Digest { + if x != nil { + if x.xxx_hidden_ChunkDigests != nil { + return *x.xxx_hidden_ChunkDigests + } + } + return nil +} + +func (x *SpliceBlobRequest) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *SpliceBlobRequest) GetChunkingFunction() ChunkingFunction_Value { + if x != nil { + return x.xxx_hidden_ChunkingFunction + } + return ChunkingFunction_UNKNOWN +} + +func (x *SpliceBlobRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +func (x *SpliceBlobRequest) SetBlobDigest(v *Digest) { + x.xxx_hidden_BlobDigest = v +} + +func (x *SpliceBlobRequest) SetChunkDigests(v []*Digest) { + x.xxx_hidden_ChunkDigests = &v +} + +func (x *SpliceBlobRequest) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *SpliceBlobRequest) SetChunkingFunction(v ChunkingFunction_Value) { + x.xxx_hidden_ChunkingFunction = v +} + +func (x *SpliceBlobRequest) HasBlobDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_BlobDigest != nil +} + +func (x *SpliceBlobRequest) ClearBlobDigest() { + x.xxx_hidden_BlobDigest = nil +} + +type SpliceBlobRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string + // Expected digest of the spliced blob. The client MUST set this field due + // to the following reasons: + // 1. It allows the server to perform an early existence check of the blob + // or existing chunks that assemble the blob before spending the splicing + // effort, as described in the [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob] + // documentation. + // 2. It allows servers with different storage backends to dispatch the + // request to the correct storage backend based on the size and/or the + // hash of the blob. + // 3. If chunking information already exists for the blob, it allows + // the server to keep the existing chunking information or replace it with + // new chunking information. + BlobDigest *Digest + // The ordered list of digests of the chunks which need to be concatenated to + // assemble the original blob. + ChunkDigests []*Digest + // The digest function of all chunks to be concatenated and of the blob to be + // spliced. The server MUST use the same digest function for both cases. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, SHA384, + // SHA512, or VSO, the client MAY leave this field unset. In that case the + // server SHOULD infer the digest function using the length of the blob digest + // hashes and the digest functions announced in the server's capabilities. + DigestFunction DigestFunction_Value + // The chunking function that the client used to split the blob. + ChunkingFunction ChunkingFunction_Value +} + +func (b0 SpliceBlobRequest_builder) Build() *SpliceBlobRequest { + m0 := &SpliceBlobRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + x.xxx_hidden_BlobDigest = b.BlobDigest + x.xxx_hidden_ChunkDigests = &b.ChunkDigests + x.xxx_hidden_DigestFunction = b.DigestFunction + x.xxx_hidden_ChunkingFunction = b.ChunkingFunction + return m0 +} + +// A response message for +// [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob]. +type SpliceBlobResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_BlobDigest *Digest `protobuf:"bytes,1,opt,name=blob_digest,json=blobDigest,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SpliceBlobResponse) Reset() { + *x = SpliceBlobResponse{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SpliceBlobResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SpliceBlobResponse) ProtoMessage() {} + +func (x *SpliceBlobResponse) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[37] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SpliceBlobResponse) GetBlobDigest() *Digest { + if x != nil { + return x.xxx_hidden_BlobDigest + } + return nil +} + +func (x *SpliceBlobResponse) SetBlobDigest(v *Digest) { + x.xxx_hidden_BlobDigest = v +} + +func (x *SpliceBlobResponse) HasBlobDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_BlobDigest != nil +} + +func (x *SpliceBlobResponse) ClearBlobDigest() { + x.xxx_hidden_BlobDigest = nil +} + +type SpliceBlobResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Computed digest of the spliced blob. + // + // The server MUST use the same digest function as the one explicitly or + // implicitly (through hash length) specified in the splice request. + BlobDigest *Digest +} + +func (b0 SpliceBlobResponse_builder) Build() *SpliceBlobResponse { + m0 := &SpliceBlobResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_BlobDigest = b.BlobDigest + return m0 +} + +// A request message for +// [Capabilities.GetCapabilities][build.bazel.remote.execution.v2.Capabilities.GetCapabilities]. +type GetCapabilitiesRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InstanceName string `protobuf:"bytes,1,opt,name=instance_name,json=instanceName,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetCapabilitiesRequest) Reset() { + *x = GetCapabilitiesRequest{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetCapabilitiesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCapabilitiesRequest) ProtoMessage() {} + +func (x *GetCapabilitiesRequest) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[38] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetCapabilitiesRequest) GetInstanceName() string { + if x != nil { + return x.xxx_hidden_InstanceName + } + return "" +} + +func (x *GetCapabilitiesRequest) SetInstanceName(v string) { + x.xxx_hidden_InstanceName = v +} + +type GetCapabilitiesRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + InstanceName string +} + +func (b0 GetCapabilitiesRequest_builder) Build() *GetCapabilitiesRequest { + m0 := &GetCapabilitiesRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InstanceName = b.InstanceName + return m0 +} + +// A response message for +// [Capabilities.GetCapabilities][build.bazel.remote.execution.v2.Capabilities.GetCapabilities]. +type ServerCapabilities struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_CacheCapabilities *CacheCapabilities `protobuf:"bytes,1,opt,name=cache_capabilities,json=cacheCapabilities,proto3"` + xxx_hidden_ExecutionCapabilities *ExecutionCapabilities `protobuf:"bytes,2,opt,name=execution_capabilities,json=executionCapabilities,proto3"` + xxx_hidden_DeprecatedApiVersion *semver.SemVer `protobuf:"bytes,3,opt,name=deprecated_api_version,json=deprecatedApiVersion,proto3"` + xxx_hidden_LowApiVersion *semver.SemVer `protobuf:"bytes,4,opt,name=low_api_version,json=lowApiVersion,proto3"` + xxx_hidden_HighApiVersion *semver.SemVer `protobuf:"bytes,5,opt,name=high_api_version,json=highApiVersion,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServerCapabilities) Reset() { + *x = ServerCapabilities{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[39] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServerCapabilities) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerCapabilities) ProtoMessage() {} + +func (x *ServerCapabilities) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[39] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ServerCapabilities) GetCacheCapabilities() *CacheCapabilities { + if x != nil { + return x.xxx_hidden_CacheCapabilities + } + return nil +} + +func (x *ServerCapabilities) GetExecutionCapabilities() *ExecutionCapabilities { + if x != nil { + return x.xxx_hidden_ExecutionCapabilities + } + return nil +} + +func (x *ServerCapabilities) GetDeprecatedApiVersion() *semver.SemVer { + if x != nil { + return x.xxx_hidden_DeprecatedApiVersion + } + return nil +} + +func (x *ServerCapabilities) GetLowApiVersion() *semver.SemVer { + if x != nil { + return x.xxx_hidden_LowApiVersion + } + return nil +} + +func (x *ServerCapabilities) GetHighApiVersion() *semver.SemVer { + if x != nil { + return x.xxx_hidden_HighApiVersion + } + return nil +} + +func (x *ServerCapabilities) SetCacheCapabilities(v *CacheCapabilities) { + x.xxx_hidden_CacheCapabilities = v +} + +func (x *ServerCapabilities) SetExecutionCapabilities(v *ExecutionCapabilities) { + x.xxx_hidden_ExecutionCapabilities = v +} + +func (x *ServerCapabilities) SetDeprecatedApiVersion(v *semver.SemVer) { + x.xxx_hidden_DeprecatedApiVersion = v +} + +func (x *ServerCapabilities) SetLowApiVersion(v *semver.SemVer) { + x.xxx_hidden_LowApiVersion = v +} + +func (x *ServerCapabilities) SetHighApiVersion(v *semver.SemVer) { + x.xxx_hidden_HighApiVersion = v +} + +func (x *ServerCapabilities) HasCacheCapabilities() bool { + if x == nil { + return false + } + return x.xxx_hidden_CacheCapabilities != nil +} + +func (x *ServerCapabilities) HasExecutionCapabilities() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExecutionCapabilities != nil +} + +func (x *ServerCapabilities) HasDeprecatedApiVersion() bool { + if x == nil { + return false + } + return x.xxx_hidden_DeprecatedApiVersion != nil +} + +func (x *ServerCapabilities) HasLowApiVersion() bool { + if x == nil { + return false + } + return x.xxx_hidden_LowApiVersion != nil +} + +func (x *ServerCapabilities) HasHighApiVersion() bool { + if x == nil { + return false + } + return x.xxx_hidden_HighApiVersion != nil +} + +func (x *ServerCapabilities) ClearCacheCapabilities() { + x.xxx_hidden_CacheCapabilities = nil +} + +func (x *ServerCapabilities) ClearExecutionCapabilities() { + x.xxx_hidden_ExecutionCapabilities = nil +} + +func (x *ServerCapabilities) ClearDeprecatedApiVersion() { + x.xxx_hidden_DeprecatedApiVersion = nil +} + +func (x *ServerCapabilities) ClearLowApiVersion() { + x.xxx_hidden_LowApiVersion = nil +} + +func (x *ServerCapabilities) ClearHighApiVersion() { + x.xxx_hidden_HighApiVersion = nil +} + +type ServerCapabilities_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Capabilities of the remote cache system. + CacheCapabilities *CacheCapabilities + // Capabilities of the remote execution system. + ExecutionCapabilities *ExecutionCapabilities + // Earliest RE API version supported, including deprecated versions. + DeprecatedApiVersion *semver.SemVer + // Earliest non-deprecated RE API version supported. + LowApiVersion *semver.SemVer + // Latest RE API version supported. + HighApiVersion *semver.SemVer +} + +func (b0 ServerCapabilities_builder) Build() *ServerCapabilities { + m0 := &ServerCapabilities{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_CacheCapabilities = b.CacheCapabilities + x.xxx_hidden_ExecutionCapabilities = b.ExecutionCapabilities + x.xxx_hidden_DeprecatedApiVersion = b.DeprecatedApiVersion + x.xxx_hidden_LowApiVersion = b.LowApiVersion + x.xxx_hidden_HighApiVersion = b.HighApiVersion + return m0 +} + +// The digest function used for converting values into keys for CAS and Action +// Cache. +type DigestFunction struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DigestFunction) Reset() { + *x = DigestFunction{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[40] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DigestFunction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DigestFunction) ProtoMessage() {} + +func (x *DigestFunction) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[40] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type DigestFunction_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 DigestFunction_builder) Build() *DigestFunction { + m0 := &DigestFunction{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +// The chunking function is used to split a blob into chunks. +// +// The server advertises support for a chunking function by setting the +// corresponding params field in +// [CacheCapabilities][build.bazel.remote.execution.v2.CacheCapabilities]. +// For example, if fast_cdc_2020_params is set, the server supports FAST_CDC_2020. +// +// For optimal deduplication, clients SHOULD use an advertised chunking function. +// When clients use UNKNOWN, the server chooses an algorithm for SplitBlob and +// simply verifies chunk concatenation for SpliceBlob. +type ChunkingFunction struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ChunkingFunction) Reset() { + *x = ChunkingFunction{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[41] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChunkingFunction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChunkingFunction) ProtoMessage() {} + +func (x *ChunkingFunction) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[41] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type ChunkingFunction_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 ChunkingFunction_builder) Build() *ChunkingFunction { + m0 := &ChunkingFunction{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +// Describes the server/instance capabilities for updating the action cache. +type ActionCacheUpdateCapabilities struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_UpdateEnabled bool `protobuf:"varint,1,opt,name=update_enabled,json=updateEnabled,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ActionCacheUpdateCapabilities) Reset() { + *x = ActionCacheUpdateCapabilities{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ActionCacheUpdateCapabilities) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActionCacheUpdateCapabilities) ProtoMessage() {} + +func (x *ActionCacheUpdateCapabilities) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[42] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ActionCacheUpdateCapabilities) GetUpdateEnabled() bool { + if x != nil { + return x.xxx_hidden_UpdateEnabled + } + return false +} + +func (x *ActionCacheUpdateCapabilities) SetUpdateEnabled(v bool) { + x.xxx_hidden_UpdateEnabled = v +} + +type ActionCacheUpdateCapabilities_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + UpdateEnabled bool +} + +func (b0 ActionCacheUpdateCapabilities_builder) Build() *ActionCacheUpdateCapabilities { + m0 := &ActionCacheUpdateCapabilities{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_UpdateEnabled = b.UpdateEnabled + return m0 +} + +// Allowed values for priority in +// [ResultsCachePolicy][build.bazel.remote.execution.v2.ResultsCachePolicy] and +// [ExecutionPolicy][build.bazel.remote.execution.v2.ExecutionPolicy] +// Used for querying both cache and execution valid priority ranges. +type PriorityCapabilities struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Priorities *[]*PriorityCapabilities_PriorityRange `protobuf:"bytes,1,rep,name=priorities,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PriorityCapabilities) Reset() { + *x = PriorityCapabilities{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[43] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PriorityCapabilities) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PriorityCapabilities) ProtoMessage() {} + +func (x *PriorityCapabilities) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[43] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *PriorityCapabilities) GetPriorities() []*PriorityCapabilities_PriorityRange { + if x != nil { + if x.xxx_hidden_Priorities != nil { + return *x.xxx_hidden_Priorities + } + } + return nil +} + +func (x *PriorityCapabilities) SetPriorities(v []*PriorityCapabilities_PriorityRange) { + x.xxx_hidden_Priorities = &v +} + +type PriorityCapabilities_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Priorities []*PriorityCapabilities_PriorityRange +} + +func (b0 PriorityCapabilities_builder) Build() *PriorityCapabilities { + m0 := &PriorityCapabilities{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Priorities = &b.Priorities + return m0 +} + +// Describes how the server treats absolute symlink targets. +type SymlinkAbsolutePathStrategy struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SymlinkAbsolutePathStrategy) Reset() { + *x = SymlinkAbsolutePathStrategy{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[44] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SymlinkAbsolutePathStrategy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SymlinkAbsolutePathStrategy) ProtoMessage() {} + +func (x *SymlinkAbsolutePathStrategy) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[44] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type SymlinkAbsolutePathStrategy_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 SymlinkAbsolutePathStrategy_builder) Build() *SymlinkAbsolutePathStrategy { + m0 := &SymlinkAbsolutePathStrategy{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +// Compression formats which may be supported. +type Compressor struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Compressor) Reset() { + *x = Compressor{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[45] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Compressor) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Compressor) ProtoMessage() {} + +func (x *Compressor) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[45] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type Compressor_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 Compressor_builder) Build() *Compressor { + m0 := &Compressor{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +// Capabilities of the remote cache system. +type CacheCapabilities struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_DigestFunctions []DigestFunction_Value `protobuf:"varint,1,rep,packed,name=digest_functions,json=digestFunctions,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + xxx_hidden_ActionCacheUpdateCapabilities *ActionCacheUpdateCapabilities `protobuf:"bytes,2,opt,name=action_cache_update_capabilities,json=actionCacheUpdateCapabilities,proto3"` + xxx_hidden_CachePriorityCapabilities *PriorityCapabilities `protobuf:"bytes,3,opt,name=cache_priority_capabilities,json=cachePriorityCapabilities,proto3"` + xxx_hidden_MaxBatchTotalSizeBytes int64 `protobuf:"varint,4,opt,name=max_batch_total_size_bytes,json=maxBatchTotalSizeBytes,proto3"` + xxx_hidden_SymlinkAbsolutePathStrategy SymlinkAbsolutePathStrategy_Value `protobuf:"varint,5,opt,name=symlink_absolute_path_strategy,json=symlinkAbsolutePathStrategy,proto3,enum=build.bazel.remote.execution.v2.SymlinkAbsolutePathStrategy_Value"` + xxx_hidden_SupportedCompressors []Compressor_Value `protobuf:"varint,6,rep,packed,name=supported_compressors,json=supportedCompressors,proto3,enum=build.bazel.remote.execution.v2.Compressor_Value"` + xxx_hidden_SupportedBatchUpdateCompressors []Compressor_Value `protobuf:"varint,7,rep,packed,name=supported_batch_update_compressors,json=supportedBatchUpdateCompressors,proto3,enum=build.bazel.remote.execution.v2.Compressor_Value"` + xxx_hidden_MaxCasBlobSizeBytes int64 `protobuf:"varint,8,opt,name=max_cas_blob_size_bytes,json=maxCasBlobSizeBytes,proto3"` + xxx_hidden_SplitBlobSupport bool `protobuf:"varint,9,opt,name=split_blob_support,json=splitBlobSupport,proto3"` + xxx_hidden_SpliceBlobSupport bool `protobuf:"varint,10,opt,name=splice_blob_support,json=spliceBlobSupport,proto3"` + xxx_hidden_FastCdc_2020Params *FastCdc2020Params `protobuf:"bytes,11,opt,name=fast_cdc_2020_params,json=fastCdc2020Params,proto3"` + xxx_hidden_RepMaxCdcParams *RepMaxCdcParams `protobuf:"bytes,12,opt,name=rep_max_cdc_params,json=repMaxCdcParams,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CacheCapabilities) Reset() { + *x = CacheCapabilities{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[46] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CacheCapabilities) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CacheCapabilities) ProtoMessage() {} + +func (x *CacheCapabilities) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[46] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *CacheCapabilities) GetDigestFunctions() []DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunctions + } + return nil +} + +func (x *CacheCapabilities) GetActionCacheUpdateCapabilities() *ActionCacheUpdateCapabilities { + if x != nil { + return x.xxx_hidden_ActionCacheUpdateCapabilities + } + return nil +} + +func (x *CacheCapabilities) GetCachePriorityCapabilities() *PriorityCapabilities { + if x != nil { + return x.xxx_hidden_CachePriorityCapabilities + } + return nil +} + +func (x *CacheCapabilities) GetMaxBatchTotalSizeBytes() int64 { + if x != nil { + return x.xxx_hidden_MaxBatchTotalSizeBytes + } + return 0 +} + +func (x *CacheCapabilities) GetSymlinkAbsolutePathStrategy() SymlinkAbsolutePathStrategy_Value { + if x != nil { + return x.xxx_hidden_SymlinkAbsolutePathStrategy + } + return SymlinkAbsolutePathStrategy_UNKNOWN +} + +func (x *CacheCapabilities) GetSupportedCompressors() []Compressor_Value { + if x != nil { + return x.xxx_hidden_SupportedCompressors + } + return nil +} + +func (x *CacheCapabilities) GetSupportedBatchUpdateCompressors() []Compressor_Value { + if x != nil { + return x.xxx_hidden_SupportedBatchUpdateCompressors + } + return nil +} + +func (x *CacheCapabilities) GetMaxCasBlobSizeBytes() int64 { + if x != nil { + return x.xxx_hidden_MaxCasBlobSizeBytes + } + return 0 +} + +func (x *CacheCapabilities) GetSplitBlobSupport() bool { + if x != nil { + return x.xxx_hidden_SplitBlobSupport + } + return false +} + +func (x *CacheCapabilities) GetSpliceBlobSupport() bool { + if x != nil { + return x.xxx_hidden_SpliceBlobSupport + } + return false +} + +func (x *CacheCapabilities) GetFastCdc_2020Params() *FastCdc2020Params { + if x != nil { + return x.xxx_hidden_FastCdc_2020Params + } + return nil +} + +func (x *CacheCapabilities) GetRepMaxCdcParams() *RepMaxCdcParams { + if x != nil { + return x.xxx_hidden_RepMaxCdcParams + } + return nil +} + +func (x *CacheCapabilities) SetDigestFunctions(v []DigestFunction_Value) { + x.xxx_hidden_DigestFunctions = v +} + +func (x *CacheCapabilities) SetActionCacheUpdateCapabilities(v *ActionCacheUpdateCapabilities) { + x.xxx_hidden_ActionCacheUpdateCapabilities = v +} + +func (x *CacheCapabilities) SetCachePriorityCapabilities(v *PriorityCapabilities) { + x.xxx_hidden_CachePriorityCapabilities = v +} + +func (x *CacheCapabilities) SetMaxBatchTotalSizeBytes(v int64) { + x.xxx_hidden_MaxBatchTotalSizeBytes = v +} + +func (x *CacheCapabilities) SetSymlinkAbsolutePathStrategy(v SymlinkAbsolutePathStrategy_Value) { + x.xxx_hidden_SymlinkAbsolutePathStrategy = v +} + +func (x *CacheCapabilities) SetSupportedCompressors(v []Compressor_Value) { + x.xxx_hidden_SupportedCompressors = v +} + +func (x *CacheCapabilities) SetSupportedBatchUpdateCompressors(v []Compressor_Value) { + x.xxx_hidden_SupportedBatchUpdateCompressors = v +} + +func (x *CacheCapabilities) SetMaxCasBlobSizeBytes(v int64) { + x.xxx_hidden_MaxCasBlobSizeBytes = v +} + +func (x *CacheCapabilities) SetSplitBlobSupport(v bool) { + x.xxx_hidden_SplitBlobSupport = v +} + +func (x *CacheCapabilities) SetSpliceBlobSupport(v bool) { + x.xxx_hidden_SpliceBlobSupport = v +} + +func (x *CacheCapabilities) SetFastCdc_2020Params(v *FastCdc2020Params) { + x.xxx_hidden_FastCdc_2020Params = v +} + +func (x *CacheCapabilities) SetRepMaxCdcParams(v *RepMaxCdcParams) { + x.xxx_hidden_RepMaxCdcParams = v +} + +func (x *CacheCapabilities) HasActionCacheUpdateCapabilities() bool { + if x == nil { + return false + } + return x.xxx_hidden_ActionCacheUpdateCapabilities != nil +} + +func (x *CacheCapabilities) HasCachePriorityCapabilities() bool { + if x == nil { + return false + } + return x.xxx_hidden_CachePriorityCapabilities != nil +} + +func (x *CacheCapabilities) HasFastCdc_2020Params() bool { + if x == nil { + return false + } + return x.xxx_hidden_FastCdc_2020Params != nil +} + +func (x *CacheCapabilities) HasRepMaxCdcParams() bool { + if x == nil { + return false + } + return x.xxx_hidden_RepMaxCdcParams != nil +} + +func (x *CacheCapabilities) ClearActionCacheUpdateCapabilities() { + x.xxx_hidden_ActionCacheUpdateCapabilities = nil +} + +func (x *CacheCapabilities) ClearCachePriorityCapabilities() { + x.xxx_hidden_CachePriorityCapabilities = nil +} + +func (x *CacheCapabilities) ClearFastCdc_2020Params() { + x.xxx_hidden_FastCdc_2020Params = nil +} + +func (x *CacheCapabilities) ClearRepMaxCdcParams() { + x.xxx_hidden_RepMaxCdcParams = nil +} + +type CacheCapabilities_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // All the digest functions supported by the remote cache. + // Remote cache may support multiple digest functions simultaneously. + DigestFunctions []DigestFunction_Value + // Capabilities for updating the action cache. + ActionCacheUpdateCapabilities *ActionCacheUpdateCapabilities + // Supported cache priority range for both CAS and ActionCache. + CachePriorityCapabilities *PriorityCapabilities + // Maximum total size of blobs to be uploaded/downloaded using + // batch methods. A value of 0 means no limit is set, although + // in practice there will always be a message size limitation + // of the protocol in use, e.g. GRPC. + MaxBatchTotalSizeBytes int64 + // Whether absolute symlink targets are supported. + SymlinkAbsolutePathStrategy SymlinkAbsolutePathStrategy_Value + // Compressors supported by the "compressed-blobs" bytestream resources. + // Servers MUST support identity/no-compression, even if it is not listed + // here. + // + // Note that this does not imply which if any compressors are supported by + // the server at the gRPC level. + SupportedCompressors []Compressor_Value + // Compressors supported for inlined data in + // [BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs] + // requests. + SupportedBatchUpdateCompressors []Compressor_Value + // The maximum blob size that the server will accept for CAS blob uploads. + // - If it is 0, it means there is no limit set. A client may assume + // arbitrarily large blobs may be uploaded to and downloaded from the cache. + // - If it is larger than 0, implementations SHOULD NOT attempt to upload + // blobs with size larger than the limit. Servers SHOULD reject blob + // uploads over the `max_cas_blob_size_bytes` limit with response code + // `INVALID_ARGUMENT` + // - If the cache implementation returns a given limit, it MAY still serve + // blobs larger than this limit. + MaxCasBlobSizeBytes int64 + // Whether blob splitting is supported for the particular server/instance. If + // yes, the server/instance implements the specified behavior for blob + // splitting and a meaningful result can be expected from the + // [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // operation. + SplitBlobSupport bool + // Whether blob splicing is supported for the particular server/instance. If + // yes, the server/instance implements the specified behavior for blob + // splicing and a meaningful result can be expected from the + // [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob] + // operation. + SpliceBlobSupport bool + // The parameters for the FastCDC 2020 chunking algorithm. + // If set, the server supports the FastCDC chunking algorithm. + FastCdc_2020Params *FastCdc2020Params + // The parameters for the RepMaxCDC chunking algorithm. + // If set, the server supports the RepMaxCDC chunking algorithm. + RepMaxCdcParams *RepMaxCdcParams +} + +func (b0 CacheCapabilities_builder) Build() *CacheCapabilities { + m0 := &CacheCapabilities{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_DigestFunctions = b.DigestFunctions + x.xxx_hidden_ActionCacheUpdateCapabilities = b.ActionCacheUpdateCapabilities + x.xxx_hidden_CachePriorityCapabilities = b.CachePriorityCapabilities + x.xxx_hidden_MaxBatchTotalSizeBytes = b.MaxBatchTotalSizeBytes + x.xxx_hidden_SymlinkAbsolutePathStrategy = b.SymlinkAbsolutePathStrategy + x.xxx_hidden_SupportedCompressors = b.SupportedCompressors + x.xxx_hidden_SupportedBatchUpdateCompressors = b.SupportedBatchUpdateCompressors + x.xxx_hidden_MaxCasBlobSizeBytes = b.MaxCasBlobSizeBytes + x.xxx_hidden_SplitBlobSupport = b.SplitBlobSupport + x.xxx_hidden_SpliceBlobSupport = b.SpliceBlobSupport + x.xxx_hidden_FastCdc_2020Params = b.FastCdc_2020Params + x.xxx_hidden_RepMaxCdcParams = b.RepMaxCdcParams + return m0 +} + +// Parameters for the FastCDC content-defined chunking algorithm. +// +// Implementations MUST follow the FastCDC 2020 paper by Wen Xia, et al.: +// https://ieeexplore.ieee.org/document/9055082 +// +// Supported implementations: +// - Rust: https://docs.rs/fastcdc/3.2.1/fastcdc/v2020/index.html +// - Go: https://github.com/buildbuddy-io/fastcdc2020 +// +// Test vectors can be found in the accompanying fastcdc2020_test_vectors.txt file. +// +// Implementations MUST use normalization level 2, which has been found +// successful for build artifacts with an average chunk size of 512 KiB. +// +// Key algorithm components from the paper: +// +// GEAR table: 256 64-bit integers for the rolling hash, computed as: +// +// GEAR[i] = high_64_bits(MD5(byte(i))) for i in 0..255 +// +// MASKS table: Bit patterns for chunk boundary detection, derived from +// the C reference implementation. The mask selection based on average +// chunk size SHOULD match the paper. +// +// The minimum and maximum chunk sizes MUST be derived from the average: +// - min_chunk_size = avg_chunk_size_bytes / 4 +// - max_chunk_size = avg_chunk_size_bytes * 4 +// +// Blobs smaller than max_chunk_size (avg_chunk_size_bytes * 4) SHOULD be +// uploaded without chunking. +// +// If any of the advertised parameters are not within the expected range, +// the client SHOULD ignore FastCDC chunking function support. +type FastCdc2020Params struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_AvgChunkSizeBytes uint64 `protobuf:"varint,1,opt,name=avg_chunk_size_bytes,json=avgChunkSizeBytes,proto3"` + xxx_hidden_Seed uint32 `protobuf:"varint,2,opt,name=seed,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *FastCdc2020Params) Reset() { + *x = FastCdc2020Params{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[47] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FastCdc2020Params) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FastCdc2020Params) ProtoMessage() {} + +func (x *FastCdc2020Params) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[47] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *FastCdc2020Params) GetAvgChunkSizeBytes() uint64 { + if x != nil { + return x.xxx_hidden_AvgChunkSizeBytes + } + return 0 +} + +func (x *FastCdc2020Params) GetSeed() uint32 { + if x != nil { + return x.xxx_hidden_Seed + } + return 0 +} + +func (x *FastCdc2020Params) SetAvgChunkSizeBytes(v uint64) { + x.xxx_hidden_AvgChunkSizeBytes = v +} + +func (x *FastCdc2020Params) SetSeed(v uint32) { + x.xxx_hidden_Seed = v +} + +type FastCdc2020Params_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The average (expected) chunk size for the FastCDC chunking algorithm. + // The value MUST be between 1 KiB and 1 MiB. The recommended value is + // 524288 (512 KiB). + AvgChunkSizeBytes uint64 + // The seed for the FastCDC mask generation. + // The recommended value is 0. + // + // All clients sharing a cache SHOULD use the same seed to maximize + // chunk reuse. + Seed uint32 +} + +func (b0 FastCdc2020Params_builder) Build() *FastCdc2020Params { + m0 := &FastCdc2020Params{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_AvgChunkSizeBytes = b.AvgChunkSizeBytes + x.xxx_hidden_Seed = b.Seed + return m0 +} + +// Parameters for the RepMaxCDC content-defined chunking algorithm. +// +// Supported implementations: +// - Go: https://github.com/buildbarn/go-cdc +// +// Key algorithm components: +// +// GEAR table: 256 64-bit integers for the rolling hash, computed as: +// +// GEAR[i] = high_64_bits(MD5(byte(i))) for i in 0..255 +// +// The algorithm repeatedly applies chunking until all chunks are in the +// range [min_chunk_size_bytes, 2*min_chunk_size_bytes). Cutting points are +// selected where the Gear rolling hash is maximized within a lookahead +// window of horizon_size_bytes. +// +// If any of the advertised parameters are not within the expected range, +// the client SHOULD ignore RepMaxCDC chunking function support. +type RepMaxCdcParams struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_MinChunkSizeBytes uint64 `protobuf:"varint,1,opt,name=min_chunk_size_bytes,json=minChunkSizeBytes,proto3"` + xxx_hidden_HorizonSizeBytes uint64 `protobuf:"varint,2,opt,name=horizon_size_bytes,json=horizonSizeBytes,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RepMaxCdcParams) Reset() { + *x = RepMaxCdcParams{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[48] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RepMaxCdcParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RepMaxCdcParams) ProtoMessage() {} + +func (x *RepMaxCdcParams) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[48] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *RepMaxCdcParams) GetMinChunkSizeBytes() uint64 { + if x != nil { + return x.xxx_hidden_MinChunkSizeBytes + } + return 0 +} + +func (x *RepMaxCdcParams) GetHorizonSizeBytes() uint64 { + if x != nil { + return x.xxx_hidden_HorizonSizeBytes + } + return 0 +} + +func (x *RepMaxCdcParams) SetMinChunkSizeBytes(v uint64) { + x.xxx_hidden_MinChunkSizeBytes = v +} + +func (x *RepMaxCdcParams) SetHorizonSizeBytes(v uint64) { + x.xxx_hidden_HorizonSizeBytes = v +} + +type RepMaxCdcParams_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The minimum chunk size for the RepMaxCDC chunking algorithm. + // The value MUST be at least 64 bytes (the Gear hash window size). + // All chunks will be in the range [min_chunk_size_bytes, 2*min_chunk_size_bytes). + // The recommended value is 262144 (256 KiB). + MinChunkSizeBytes uint64 + // The lookahead window for finding optimal cutting points. + // Larger values improve deduplication quality with diminishing returns. + // Setting to 0 produces uniform chunks of min_chunk_size_bytes. + // The recommended value is 8 * min_chunk_size_bytes. + HorizonSizeBytes uint64 +} + +func (b0 RepMaxCdcParams_builder) Build() *RepMaxCdcParams { + m0 := &RepMaxCdcParams{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_MinChunkSizeBytes = b.MinChunkSizeBytes + x.xxx_hidden_HorizonSizeBytes = b.HorizonSizeBytes + return m0 +} + +// Capabilities of the remote execution system. +type ExecutionCapabilities struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_DigestFunction DigestFunction_Value `protobuf:"varint,1,opt,name=digest_function,json=digestFunction,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + xxx_hidden_ExecEnabled bool `protobuf:"varint,2,opt,name=exec_enabled,json=execEnabled,proto3"` + xxx_hidden_ExecutionPriorityCapabilities *PriorityCapabilities `protobuf:"bytes,3,opt,name=execution_priority_capabilities,json=executionPriorityCapabilities,proto3"` + xxx_hidden_SupportedNodeProperties []string `protobuf:"bytes,4,rep,name=supported_node_properties,json=supportedNodeProperties,proto3"` + xxx_hidden_DigestFunctions []DigestFunction_Value `protobuf:"varint,5,rep,packed,name=digest_functions,json=digestFunctions,proto3,enum=build.bazel.remote.execution.v2.DigestFunction_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionCapabilities) Reset() { + *x = ExecutionCapabilities{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[49] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionCapabilities) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionCapabilities) ProtoMessage() {} + +func (x *ExecutionCapabilities) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[49] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ExecutionCapabilities) GetDigestFunction() DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunction + } + return DigestFunction_UNKNOWN +} + +func (x *ExecutionCapabilities) GetExecEnabled() bool { + if x != nil { + return x.xxx_hidden_ExecEnabled + } + return false +} + +func (x *ExecutionCapabilities) GetExecutionPriorityCapabilities() *PriorityCapabilities { + if x != nil { + return x.xxx_hidden_ExecutionPriorityCapabilities + } + return nil +} + +func (x *ExecutionCapabilities) GetSupportedNodeProperties() []string { + if x != nil { + return x.xxx_hidden_SupportedNodeProperties + } + return nil +} + +func (x *ExecutionCapabilities) GetDigestFunctions() []DigestFunction_Value { + if x != nil { + return x.xxx_hidden_DigestFunctions + } + return nil +} + +func (x *ExecutionCapabilities) SetDigestFunction(v DigestFunction_Value) { + x.xxx_hidden_DigestFunction = v +} + +func (x *ExecutionCapabilities) SetExecEnabled(v bool) { + x.xxx_hidden_ExecEnabled = v +} + +func (x *ExecutionCapabilities) SetExecutionPriorityCapabilities(v *PriorityCapabilities) { + x.xxx_hidden_ExecutionPriorityCapabilities = v +} + +func (x *ExecutionCapabilities) SetSupportedNodeProperties(v []string) { + x.xxx_hidden_SupportedNodeProperties = v +} + +func (x *ExecutionCapabilities) SetDigestFunctions(v []DigestFunction_Value) { + x.xxx_hidden_DigestFunctions = v +} + +func (x *ExecutionCapabilities) HasExecutionPriorityCapabilities() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExecutionPriorityCapabilities != nil +} + +func (x *ExecutionCapabilities) ClearExecutionPriorityCapabilities() { + x.xxx_hidden_ExecutionPriorityCapabilities = nil +} + +type ExecutionCapabilities_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Legacy field for indicating which digest function is supported by the + // remote execution system. It MUST be set to a value other than UNKNOWN. + // Implementations should consider the repeated digest_functions field + // first, falling back to this singular field if digest_functions is unset. + DigestFunction DigestFunction_Value + // Whether remote execution is enabled for the particular server/instance. + ExecEnabled bool + // Supported execution priority range. + ExecutionPriorityCapabilities *PriorityCapabilities + // Supported node properties. + SupportedNodeProperties []string + // All the digest functions supported by the remote execution system. + // If this field is set, it MUST also contain digest_function. + // + // Even if the remote execution system announces support for multiple + // digest functions, individual execution requests may only reference + // CAS objects using a single digest function. For example, it is not + // permitted to execute actions having both MD5 and SHA-256 hashed + // files in their input root. + // + // The CAS objects referenced by action results generated by the + // remote execution system MUST use the same digest function as the + // one used to construct the action. + DigestFunctions []DigestFunction_Value +} + +func (b0 ExecutionCapabilities_builder) Build() *ExecutionCapabilities { + m0 := &ExecutionCapabilities{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_DigestFunction = b.DigestFunction + x.xxx_hidden_ExecEnabled = b.ExecEnabled + x.xxx_hidden_ExecutionPriorityCapabilities = b.ExecutionPriorityCapabilities + x.xxx_hidden_SupportedNodeProperties = b.SupportedNodeProperties + x.xxx_hidden_DigestFunctions = b.DigestFunctions + return m0 +} + +// Details for the tool used to call the API. +type ToolDetails struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_ToolName string `protobuf:"bytes,1,opt,name=tool_name,json=toolName,proto3"` + xxx_hidden_ToolVersion string `protobuf:"bytes,2,opt,name=tool_version,json=toolVersion,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ToolDetails) Reset() { + *x = ToolDetails{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[50] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ToolDetails) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ToolDetails) ProtoMessage() {} + +func (x *ToolDetails) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[50] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ToolDetails) GetToolName() string { + if x != nil { + return x.xxx_hidden_ToolName + } + return "" +} + +func (x *ToolDetails) GetToolVersion() string { + if x != nil { + return x.xxx_hidden_ToolVersion + } + return "" +} + +func (x *ToolDetails) SetToolName(v string) { + x.xxx_hidden_ToolName = v +} + +func (x *ToolDetails) SetToolVersion(v string) { + x.xxx_hidden_ToolVersion = v +} + +type ToolDetails_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Name of the tool, e.g. bazel. + ToolName string + // Version of the tool used for the request, e.g. 5.0.3. + ToolVersion string +} + +func (b0 ToolDetails_builder) Build() *ToolDetails { + m0 := &ToolDetails{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_ToolName = b.ToolName + x.xxx_hidden_ToolVersion = b.ToolVersion + return m0 +} + +// An optional Metadata to attach to any RPC request to tell the server about an +// external context of the request. The server may use this for logging or other +// purposes. To use it, the client attaches the header to the call using the +// canonical proto serialization: +// +// * name: `build.bazel.remote.execution.v2.requestmetadata-bin` +// * contents: the base64 encoded binary `RequestMetadata` message. +// Note: the gRPC library serializes binary headers encoded in base64 by +// default (https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests). +// Therefore, if the gRPC library is used to pass/retrieve this +// metadata, the user may ignore the base64 encoding and assume it is simply +// serialized as a binary message. +type RequestMetadata struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_ToolDetails *ToolDetails `protobuf:"bytes,1,opt,name=tool_details,json=toolDetails,proto3"` + xxx_hidden_ActionId string `protobuf:"bytes,2,opt,name=action_id,json=actionId,proto3"` + xxx_hidden_ToolInvocationId string `protobuf:"bytes,3,opt,name=tool_invocation_id,json=toolInvocationId,proto3"` + xxx_hidden_CorrelatedInvocationsId string `protobuf:"bytes,4,opt,name=correlated_invocations_id,json=correlatedInvocationsId,proto3"` + xxx_hidden_ActionMnemonic string `protobuf:"bytes,5,opt,name=action_mnemonic,json=actionMnemonic,proto3"` + xxx_hidden_TargetId string `protobuf:"bytes,6,opt,name=target_id,json=targetId,proto3"` + xxx_hidden_ConfigurationId string `protobuf:"bytes,7,opt,name=configuration_id,json=configurationId,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RequestMetadata) Reset() { + *x = RequestMetadata{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[51] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestMetadata) ProtoMessage() {} + +func (x *RequestMetadata) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[51] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *RequestMetadata) GetToolDetails() *ToolDetails { + if x != nil { + return x.xxx_hidden_ToolDetails + } + return nil +} + +func (x *RequestMetadata) GetActionId() string { + if x != nil { + return x.xxx_hidden_ActionId + } + return "" +} + +func (x *RequestMetadata) GetToolInvocationId() string { + if x != nil { + return x.xxx_hidden_ToolInvocationId + } + return "" +} + +func (x *RequestMetadata) GetCorrelatedInvocationsId() string { + if x != nil { + return x.xxx_hidden_CorrelatedInvocationsId + } + return "" +} + +func (x *RequestMetadata) GetActionMnemonic() string { + if x != nil { + return x.xxx_hidden_ActionMnemonic + } + return "" +} + +func (x *RequestMetadata) GetTargetId() string { + if x != nil { + return x.xxx_hidden_TargetId + } + return "" +} + +func (x *RequestMetadata) GetConfigurationId() string { + if x != nil { + return x.xxx_hidden_ConfigurationId + } + return "" +} + +func (x *RequestMetadata) SetToolDetails(v *ToolDetails) { + x.xxx_hidden_ToolDetails = v +} + +func (x *RequestMetadata) SetActionId(v string) { + x.xxx_hidden_ActionId = v +} + +func (x *RequestMetadata) SetToolInvocationId(v string) { + x.xxx_hidden_ToolInvocationId = v +} + +func (x *RequestMetadata) SetCorrelatedInvocationsId(v string) { + x.xxx_hidden_CorrelatedInvocationsId = v +} + +func (x *RequestMetadata) SetActionMnemonic(v string) { + x.xxx_hidden_ActionMnemonic = v +} + +func (x *RequestMetadata) SetTargetId(v string) { + x.xxx_hidden_TargetId = v +} + +func (x *RequestMetadata) SetConfigurationId(v string) { + x.xxx_hidden_ConfigurationId = v +} + +func (x *RequestMetadata) HasToolDetails() bool { + if x == nil { + return false + } + return x.xxx_hidden_ToolDetails != nil +} + +func (x *RequestMetadata) ClearToolDetails() { + x.xxx_hidden_ToolDetails = nil +} + +type RequestMetadata_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The details for the tool invoking the requests. + ToolDetails *ToolDetails + // An identifier that ties multiple requests to the same action. + // For example, multiple requests to the CAS, Action Cache, and Execution + // API are used in order to compile foo.cc. + ActionId string + // An identifier that ties multiple actions together to a final result. + // For example, multiple actions are required to build and run foo_test. + ToolInvocationId string + // An identifier to tie multiple tool invocations together. For example, + // runs of foo_test, bar_test and baz_test on a post-submit of a given patch. + CorrelatedInvocationsId string + // A brief description of the kind of action, for example, CppCompile or GoLink. + // There is no standard agreed set of values for this, and they are expected to vary between different client tools. + ActionMnemonic string + // An identifier for the target which produced this action. + // No guarantees are made around how many actions may relate to a single target. + TargetId string + // An identifier for the configuration in which the target was built, + // e.g. for differentiating building host tools or different target platforms. + // There is no expectation that this value will have any particular structure, + // or equality across invocations, though some client tools may offer these guarantees. + ConfigurationId string +} + +func (b0 RequestMetadata_builder) Build() *RequestMetadata { + m0 := &RequestMetadata{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_ToolDetails = b.ToolDetails + x.xxx_hidden_ActionId = b.ActionId + x.xxx_hidden_ToolInvocationId = b.ToolInvocationId + x.xxx_hidden_CorrelatedInvocationsId = b.CorrelatedInvocationsId + x.xxx_hidden_ActionMnemonic = b.ActionMnemonic + x.xxx_hidden_TargetId = b.TargetId + x.xxx_hidden_ConfigurationId = b.ConfigurationId + return m0 +} + +// An `EnvironmentVariable` is one variable to set in the running program's +// environment. +type Command_EnvironmentVariable struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3"` + xxx_hidden_Value string `protobuf:"bytes,2,opt,name=value,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Command_EnvironmentVariable) Reset() { + *x = Command_EnvironmentVariable{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[52] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Command_EnvironmentVariable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Command_EnvironmentVariable) ProtoMessage() {} + +func (x *Command_EnvironmentVariable) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[52] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Command_EnvironmentVariable) GetName() string { + if x != nil { + return x.xxx_hidden_Name + } + return "" +} + +func (x *Command_EnvironmentVariable) GetValue() string { + if x != nil { + return x.xxx_hidden_Value + } + return "" +} + +func (x *Command_EnvironmentVariable) SetName(v string) { + x.xxx_hidden_Name = v +} + +func (x *Command_EnvironmentVariable) SetValue(v string) { + x.xxx_hidden_Value = v +} + +type Command_EnvironmentVariable_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The variable name. + Name string + // The variable value. + Value string +} + +func (b0 Command_EnvironmentVariable_builder) Build() *Command_EnvironmentVariable { + m0 := &Command_EnvironmentVariable{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + x.xxx_hidden_Value = b.Value + return m0 +} + +// A single property for the environment. The server is responsible for +// specifying the property `name`s that it accepts. If an unknown `name` is +// provided in the requirements for an +// [Action][build.bazel.remote.execution.v2.Action], the server SHOULD +// reject the execution request. If permitted by the server, the same `name` +// may occur multiple times. +// +// The server is also responsible for specifying the interpretation of +// property `value`s. For instance, a property describing how much RAM must be +// available may be interpreted as allowing a worker with 16GB to fulfill a +// request for 8GB, while a property describing the OS environment on which +// the action must be performed may require an exact match with the worker's +// OS. +// +// The server MAY use the `value` of one or more properties to determine how +// it sets up the execution environment, such as by making specific system +// files available to the worker. +// +// Both names and values are typically case-sensitive. Note that the platform +// is implicitly part of the action digest, so even tiny changes in the names +// or values (like changing case) may result in different action cache +// entries. +type Platform_Property struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3"` + xxx_hidden_Value string `protobuf:"bytes,2,opt,name=value,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Platform_Property) Reset() { + *x = Platform_Property{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[53] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Platform_Property) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Platform_Property) ProtoMessage() {} + +func (x *Platform_Property) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[53] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Platform_Property) GetName() string { + if x != nil { + return x.xxx_hidden_Name + } + return "" +} + +func (x *Platform_Property) GetValue() string { + if x != nil { + return x.xxx_hidden_Value + } + return "" +} + +func (x *Platform_Property) SetName(v string) { + x.xxx_hidden_Name = v +} + +func (x *Platform_Property) SetValue(v string) { + x.xxx_hidden_Value = v +} + +type Platform_Property_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The property name. + Name string + // The property value. + Value string +} + +func (b0 Platform_Property_builder) Build() *Platform_Property { + m0 := &Platform_Property{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + x.xxx_hidden_Value = b.Value + return m0 +} + +// A request corresponding to a single blob that the client wants to upload. +type BatchUpdateBlobsRequest_Request struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Digest *Digest `protobuf:"bytes,1,opt,name=digest,proto3"` + xxx_hidden_Data []byte `protobuf:"bytes,2,opt,name=data,proto3"` + xxx_hidden_Compressor Compressor_Value `protobuf:"varint,3,opt,name=compressor,proto3,enum=build.bazel.remote.execution.v2.Compressor_Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BatchUpdateBlobsRequest_Request) Reset() { + *x = BatchUpdateBlobsRequest_Request{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[55] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BatchUpdateBlobsRequest_Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchUpdateBlobsRequest_Request) ProtoMessage() {} + +func (x *BatchUpdateBlobsRequest_Request) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[55] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *BatchUpdateBlobsRequest_Request) GetDigest() *Digest { + if x != nil { + return x.xxx_hidden_Digest + } + return nil +} + +func (x *BatchUpdateBlobsRequest_Request) GetData() []byte { + if x != nil { + return x.xxx_hidden_Data + } + return nil +} + +func (x *BatchUpdateBlobsRequest_Request) GetCompressor() Compressor_Value { + if x != nil { + return x.xxx_hidden_Compressor + } + return Compressor_IDENTITY +} + +func (x *BatchUpdateBlobsRequest_Request) SetDigest(v *Digest) { + x.xxx_hidden_Digest = v +} + +func (x *BatchUpdateBlobsRequest_Request) SetData(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_Data = v +} + +func (x *BatchUpdateBlobsRequest_Request) SetCompressor(v Compressor_Value) { + x.xxx_hidden_Compressor = v +} + +func (x *BatchUpdateBlobsRequest_Request) HasDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_Digest != nil +} + +func (x *BatchUpdateBlobsRequest_Request) ClearDigest() { + x.xxx_hidden_Digest = nil +} + +type BatchUpdateBlobsRequest_Request_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The digest of the blob. This MUST be the digest of `data`. All + // digests MUST use the same digest function. + Digest *Digest + // The raw binary data. + Data []byte + // The format of `data`. Must be `IDENTITY`/unspecified, or one of the + // compressors advertised by the + // [CacheCapabilities.supported_batch_update_compressors][build.bazel.remote.execution.v2.CacheCapabilities.supported_batch_update_compressors] + // field. + Compressor Compressor_Value +} + +func (b0 BatchUpdateBlobsRequest_Request_builder) Build() *BatchUpdateBlobsRequest_Request { + m0 := &BatchUpdateBlobsRequest_Request{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Digest = b.Digest + x.xxx_hidden_Data = b.Data + x.xxx_hidden_Compressor = b.Compressor + return m0 +} + +// A response corresponding to a single blob that the client tried to upload. +type BatchUpdateBlobsResponse_Response struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Digest *Digest `protobuf:"bytes,1,opt,name=digest,proto3"` + xxx_hidden_Status *status.Status `protobuf:"bytes,2,opt,name=status,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BatchUpdateBlobsResponse_Response) Reset() { + *x = BatchUpdateBlobsResponse_Response{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[56] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BatchUpdateBlobsResponse_Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchUpdateBlobsResponse_Response) ProtoMessage() {} + +func (x *BatchUpdateBlobsResponse_Response) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[56] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *BatchUpdateBlobsResponse_Response) GetDigest() *Digest { + if x != nil { + return x.xxx_hidden_Digest + } + return nil +} + +func (x *BatchUpdateBlobsResponse_Response) GetStatus() *status.Status { + if x != nil { + return x.xxx_hidden_Status + } + return nil +} + +func (x *BatchUpdateBlobsResponse_Response) SetDigest(v *Digest) { + x.xxx_hidden_Digest = v +} + +func (x *BatchUpdateBlobsResponse_Response) SetStatus(v *status.Status) { + x.xxx_hidden_Status = v +} + +func (x *BatchUpdateBlobsResponse_Response) HasDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_Digest != nil +} + +func (x *BatchUpdateBlobsResponse_Response) HasStatus() bool { + if x == nil { + return false + } + return x.xxx_hidden_Status != nil +} + +func (x *BatchUpdateBlobsResponse_Response) ClearDigest() { + x.xxx_hidden_Digest = nil +} + +func (x *BatchUpdateBlobsResponse_Response) ClearStatus() { + x.xxx_hidden_Status = nil +} + +type BatchUpdateBlobsResponse_Response_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The blob digest to which this response corresponds. + Digest *Digest + // The result of attempting to upload that blob. + Status *status.Status +} + +func (b0 BatchUpdateBlobsResponse_Response_builder) Build() *BatchUpdateBlobsResponse_Response { + m0 := &BatchUpdateBlobsResponse_Response{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Digest = b.Digest + x.xxx_hidden_Status = b.Status + return m0 +} + +// A response corresponding to a single blob that the client tried to download. +type BatchReadBlobsResponse_Response struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Digest *Digest `protobuf:"bytes,1,opt,name=digest,proto3"` + xxx_hidden_Data []byte `protobuf:"bytes,2,opt,name=data,proto3"` + xxx_hidden_Compressor Compressor_Value `protobuf:"varint,4,opt,name=compressor,proto3,enum=build.bazel.remote.execution.v2.Compressor_Value"` + xxx_hidden_Status *status.Status `protobuf:"bytes,3,opt,name=status,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BatchReadBlobsResponse_Response) Reset() { + *x = BatchReadBlobsResponse_Response{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[57] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BatchReadBlobsResponse_Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BatchReadBlobsResponse_Response) ProtoMessage() {} + +func (x *BatchReadBlobsResponse_Response) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[57] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *BatchReadBlobsResponse_Response) GetDigest() *Digest { + if x != nil { + return x.xxx_hidden_Digest + } + return nil +} + +func (x *BatchReadBlobsResponse_Response) GetData() []byte { + if x != nil { + return x.xxx_hidden_Data + } + return nil +} + +func (x *BatchReadBlobsResponse_Response) GetCompressor() Compressor_Value { + if x != nil { + return x.xxx_hidden_Compressor + } + return Compressor_IDENTITY +} + +func (x *BatchReadBlobsResponse_Response) GetStatus() *status.Status { + if x != nil { + return x.xxx_hidden_Status + } + return nil +} + +func (x *BatchReadBlobsResponse_Response) SetDigest(v *Digest) { + x.xxx_hidden_Digest = v +} + +func (x *BatchReadBlobsResponse_Response) SetData(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_Data = v +} + +func (x *BatchReadBlobsResponse_Response) SetCompressor(v Compressor_Value) { + x.xxx_hidden_Compressor = v +} + +func (x *BatchReadBlobsResponse_Response) SetStatus(v *status.Status) { + x.xxx_hidden_Status = v +} + +func (x *BatchReadBlobsResponse_Response) HasDigest() bool { + if x == nil { + return false + } + return x.xxx_hidden_Digest != nil +} + +func (x *BatchReadBlobsResponse_Response) HasStatus() bool { + if x == nil { + return false + } + return x.xxx_hidden_Status != nil +} + +func (x *BatchReadBlobsResponse_Response) ClearDigest() { + x.xxx_hidden_Digest = nil +} + +func (x *BatchReadBlobsResponse_Response) ClearStatus() { + x.xxx_hidden_Status = nil +} + +type BatchReadBlobsResponse_Response_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The digest to which this response corresponds. + Digest *Digest + // The raw binary data. + Data []byte + // The format the data is encoded in. MUST be `IDENTITY`/unspecified, + // or one of the acceptable compressors specified in the `BatchReadBlobsRequest`. + Compressor Compressor_Value + // The result of attempting to download that blob. + Status *status.Status +} + +func (b0 BatchReadBlobsResponse_Response_builder) Build() *BatchReadBlobsResponse_Response { + m0 := &BatchReadBlobsResponse_Response{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Digest = b.Digest + x.xxx_hidden_Data = b.Data + x.xxx_hidden_Compressor = b.Compressor + x.xxx_hidden_Status = b.Status + return m0 +} + +// Supported range of priorities, including boundaries. +type PriorityCapabilities_PriorityRange struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_MinPriority int32 `protobuf:"varint,1,opt,name=min_priority,json=minPriority,proto3"` + xxx_hidden_MaxPriority int32 `protobuf:"varint,2,opt,name=max_priority,json=maxPriority,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PriorityCapabilities_PriorityRange) Reset() { + *x = PriorityCapabilities_PriorityRange{} + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[58] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PriorityCapabilities_PriorityRange) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PriorityCapabilities_PriorityRange) ProtoMessage() {} + +func (x *PriorityCapabilities_PriorityRange) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes[58] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *PriorityCapabilities_PriorityRange) GetMinPriority() int32 { + if x != nil { + return x.xxx_hidden_MinPriority + } + return 0 +} + +func (x *PriorityCapabilities_PriorityRange) GetMaxPriority() int32 { + if x != nil { + return x.xxx_hidden_MaxPriority + } + return 0 +} + +func (x *PriorityCapabilities_PriorityRange) SetMinPriority(v int32) { + x.xxx_hidden_MinPriority = v +} + +func (x *PriorityCapabilities_PriorityRange) SetMaxPriority(v int32) { + x.xxx_hidden_MaxPriority = v +} + +type PriorityCapabilities_PriorityRange_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The minimum numeric value for this priority range, which represents the + // most urgent task or longest retained item. + MinPriority int32 + // The maximum numeric value for this priority range, which represents the + // least urgent task or shortest retained item. + MaxPriority int32 +} + +func (b0 PriorityCapabilities_PriorityRange_builder) Build() *PriorityCapabilities_PriorityRange { + m0 := &PriorityCapabilities_PriorityRange{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_MinPriority = b.MinPriority + x.xxx_hidden_MaxPriority = b.MaxPriority + return m0 +} + +var File_build_bazel_remote_execution_v2_remote_execution_proto protoreflect.FileDescriptor + +const file_build_bazel_remote_execution_v2_remote_execution_proto_rawDesc = "" + + "\n" + + "6build/bazel/remote/execution/v2/remote_execution.proto\x12\x1fbuild.bazel.remote.execution.v2\x1a\x1fbuild/bazel/semver/semver.proto\x1a\x1cgoogle/api/annotations.proto\x1a#google/longrunning/operations.proto\x1a\x19google/protobuf/any.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x17google/rpc/status.proto\"\xeb\x02\n" + + "\x06Action\x12N\n" + + "\x0ecommand_digest\x18\x01 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\rcommandDigest\x12S\n" + + "\x11input_root_digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x0finputRootDigest\x123\n" + + "\atimeout\x18\x06 \x01(\v2\x19.google.protobuf.DurationR\atimeout\x12 \n" + + "\fdo_not_cache\x18\a \x01(\bR\n" + + "doNotCache\x12\x12\n" + + "\x04salt\x18\t \x01(\fR\x04salt\x12E\n" + + "\bplatform\x18\n" + + " \x01(\v2).build.bazel.remote.execution.v2.PlatformR\bplatformJ\x04\b\x03\x10\x06J\x04\b\b\x10\t\"\xd2\x05\n" + + "\aCommand\x12\x1c\n" + + "\targuments\x18\x01 \x03(\tR\targuments\x12q\n" + + "\x15environment_variables\x18\x02 \x03(\v2<.build.bazel.remote.execution.v2.Command.EnvironmentVariableR\x14environmentVariables\x12%\n" + + "\foutput_files\x18\x03 \x03(\tB\x02\x18\x01R\voutputFiles\x121\n" + + "\x12output_directories\x18\x04 \x03(\tB\x02\x18\x01R\x11outputDirectories\x12!\n" + + "\foutput_paths\x18\a \x03(\tR\voutputPaths\x12I\n" + + "\bplatform\x18\x05 \x01(\v2).build.bazel.remote.execution.v2.PlatformB\x02\x18\x01R\bplatform\x12+\n" + + "\x11working_directory\x18\x06 \x01(\tR\x10workingDirectory\x124\n" + + "\x16output_node_properties\x18\b \x03(\tR\x14outputNodeProperties\x12v\n" + + "\x17output_directory_format\x18\t \x01(\x0e2>.build.bazel.remote.execution.v2.Command.OutputDirectoryFormatR\x15outputDirectoryFormat\x1a?\n" + + "\x13EnvironmentVariable\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\"R\n" + + "\x15OutputDirectoryFormat\x12\r\n" + + "\tTREE_ONLY\x10\x00\x12\x12\n" + + "\x0eDIRECTORY_ONLY\x10\x01\x12\x16\n" + + "\x12TREE_AND_DIRECTORY\x10\x02\"\x94\x01\n" + + "\bPlatform\x12R\n" + + "\n" + + "properties\x18\x01 \x03(\v22.build.bazel.remote.execution.v2.Platform.PropertyR\n" + + "properties\x1a4\n" + + "\bProperty\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\"\xc8\x02\n" + + "\tDirectory\x12?\n" + + "\x05files\x18\x01 \x03(\v2).build.bazel.remote.execution.v2.FileNodeR\x05files\x12P\n" + + "\vdirectories\x18\x02 \x03(\v2..build.bazel.remote.execution.v2.DirectoryNodeR\vdirectories\x12H\n" + + "\bsymlinks\x18\x03 \x03(\v2,.build.bazel.remote.execution.v2.SymlinkNodeR\bsymlinks\x12X\n" + + "\x0fnode_properties\x18\x05 \x01(\v2/.build.bazel.remote.execution.v2.NodePropertiesR\x0enodePropertiesJ\x04\b\x04\x10\x05\"8\n" + + "\fNodeProperty\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\"\xcc\x01\n" + + "\x0eNodeProperties\x12M\n" + + "\n" + + "properties\x18\x01 \x03(\v2-.build.bazel.remote.execution.v2.NodePropertyR\n" + + "properties\x120\n" + + "\x05mtime\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x05mtime\x129\n" + + "\tunix_mode\x18\x03 \x01(\v2\x1c.google.protobuf.UInt32ValueR\bunixMode\"\xea\x01\n" + + "\bFileNode\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12?\n" + + "\x06digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x06digest\x12#\n" + + "\ris_executable\x18\x04 \x01(\bR\fisExecutable\x12X\n" + + "\x0fnode_properties\x18\x06 \x01(\v2/.build.bazel.remote.execution.v2.NodePropertiesR\x0enodePropertiesJ\x04\b\x03\x10\x04J\x04\b\x05\x10\x06\"d\n" + + "\rDirectoryNode\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12?\n" + + "\x06digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x06digest\"\x99\x01\n" + + "\vSymlinkNode\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x16\n" + + "\x06target\x18\x02 \x01(\tR\x06target\x12X\n" + + "\x0fnode_properties\x18\x04 \x01(\v2/.build.bazel.remote.execution.v2.NodePropertiesR\x0enodePropertiesJ\x04\b\x03\x10\x04\";\n" + + "\x06Digest\x12\x12\n" + + "\x04hash\x18\x01 \x01(\tR\x04hash\x12\x1d\n" + + "\n" + + "size_bytes\x18\x02 \x01(\x03R\tsizeBytes\"\xfd\a\n" + + "\x16ExecutedActionMetadata\x12\x16\n" + + "\x06worker\x18\x01 \x01(\tR\x06worker\x12E\n" + + "\x10queued_timestamp\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x0fqueuedTimestamp\x12P\n" + + "\x16worker_start_timestamp\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x14workerStartTimestamp\x12X\n" + + "\x1aworker_completed_timestamp\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\x18workerCompletedTimestamp\x12Y\n" + + "\x1binput_fetch_start_timestamp\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\x18inputFetchStartTimestamp\x12a\n" + + "\x1finput_fetch_completed_timestamp\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\x1cinputFetchCompletedTimestamp\x12V\n" + + "\x19execution_start_timestamp\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\x17executionStartTimestamp\x12^\n" + + "\x1dexecution_completed_timestamp\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\x1bexecutionCompletedTimestamp\x12W\n" + + "\x1avirtual_execution_duration\x18\f \x01(\v2\x19.google.protobuf.DurationR\x18virtualExecutionDuration\x12]\n" + + "\x1doutput_upload_start_timestamp\x18\t \x01(\v2\x1a.google.protobuf.TimestampR\x1aoutputUploadStartTimestamp\x12e\n" + + "!output_upload_completed_timestamp\x18\n" + + " \x01(\v2\x1a.google.protobuf.TimestampR\x1eoutputUploadCompletedTimestamp\x12C\n" + + "\x12auxiliary_metadata\x18\v \x03(\v2\x14.google.protobuf.AnyR\x11auxiliaryMetadata\"\xd3\x06\n" + + "\fActionResult\x12N\n" + + "\foutput_files\x18\x02 \x03(\v2+.build.bazel.remote.execution.v2.OutputFileR\voutputFiles\x12d\n" + + "\x14output_file_symlinks\x18\n" + + " \x03(\v2..build.bazel.remote.execution.v2.OutputSymlinkB\x02\x18\x01R\x12outputFileSymlinks\x12W\n" + + "\x0foutput_symlinks\x18\f \x03(\v2..build.bazel.remote.execution.v2.OutputSymlinkR\x0eoutputSymlinks\x12_\n" + + "\x12output_directories\x18\x03 \x03(\v20.build.bazel.remote.execution.v2.OutputDirectoryR\x11outputDirectories\x12n\n" + + "\x19output_directory_symlinks\x18\v \x03(\v2..build.bazel.remote.execution.v2.OutputSymlinkB\x02\x18\x01R\x17outputDirectorySymlinks\x12\x1b\n" + + "\texit_code\x18\x04 \x01(\x05R\bexitCode\x12\x1d\n" + + "\n" + + "stdout_raw\x18\x05 \x01(\fR\tstdoutRaw\x12L\n" + + "\rstdout_digest\x18\x06 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\fstdoutDigest\x12\x1d\n" + + "\n" + + "stderr_raw\x18\a \x01(\fR\tstderrRaw\x12L\n" + + "\rstderr_digest\x18\b \x01(\v2'.build.bazel.remote.execution.v2.DigestR\fstderrDigest\x12f\n" + + "\x12execution_metadata\x18\t \x01(\v27.build.bazel.remote.execution.v2.ExecutedActionMetadataR\x11executionMetadataJ\x04\b\x01\x10\x02\"\x88\x02\n" + + "\n" + + "OutputFile\x12\x12\n" + + "\x04path\x18\x01 \x01(\tR\x04path\x12?\n" + + "\x06digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x06digest\x12#\n" + + "\ris_executable\x18\x04 \x01(\bR\fisExecutable\x12\x1a\n" + + "\bcontents\x18\x05 \x01(\fR\bcontents\x12X\n" + + "\x0fnode_properties\x18\a \x01(\v2/.build.bazel.remote.execution.v2.NodePropertiesR\x0enodePropertiesJ\x04\b\x03\x10\x04J\x04\b\x06\x10\a\"\x8e\x01\n" + + "\x04Tree\x12>\n" + + "\x04root\x18\x01 \x01(\v2*.build.bazel.remote.execution.v2.DirectoryR\x04root\x12F\n" + + "\bchildren\x18\x02 \x03(\v2*.build.bazel.remote.execution.v2.DirectoryR\bchildren\"\x8a\x02\n" + + "\x0fOutputDirectory\x12\x12\n" + + "\x04path\x18\x01 \x01(\tR\x04path\x12H\n" + + "\vtree_digest\x18\x03 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\n" + + "treeDigest\x126\n" + + "\x17is_topologically_sorted\x18\x04 \x01(\bR\x15isTopologicallySorted\x12[\n" + + "\x15root_directory_digest\x18\x05 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x13rootDirectoryDigestJ\x04\b\x02\x10\x03\"\x9b\x01\n" + + "\rOutputSymlink\x12\x12\n" + + "\x04path\x18\x01 \x01(\tR\x04path\x12\x16\n" + + "\x06target\x18\x02 \x01(\tR\x06target\x12X\n" + + "\x0fnode_properties\x18\x04 \x01(\v2/.build.bazel.remote.execution.v2.NodePropertiesR\x0enodePropertiesJ\x04\b\x03\x10\x04\"-\n" + + "\x0fExecutionPolicy\x12\x1a\n" + + "\bpriority\x18\x01 \x01(\x05R\bpriority\"0\n" + + "\x12ResultsCachePolicy\x12\x1a\n" + + "\bpriority\x18\x01 \x01(\x05R\bpriority\"\xdf\x04\n" + + "\x0eExecuteRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12*\n" + + "\x11skip_cache_lookup\x18\x03 \x01(\bR\x0fskipCacheLookup\x12L\n" + + "\raction_digest\x18\x06 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\factionDigest\x12[\n" + + "\x10execution_policy\x18\a \x01(\v20.build.bazel.remote.execution.v2.ExecutionPolicyR\x0fexecutionPolicy\x12e\n" + + "\x14results_cache_policy\x18\b \x01(\v23.build.bazel.remote.execution.v2.ResultsCachePolicyR\x12resultsCachePolicy\x12^\n" + + "\x0fdigest_function\x18\t \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\x12#\n" + + "\rinline_stdout\x18\n" + + " \x01(\bR\finlineStdout\x12#\n" + + "\rinline_stderr\x18\v \x01(\bR\finlineStderr\x12.\n" + + "\x13inline_output_files\x18\f \x03(\tR\x11inlineOutputFilesJ\x04\b\x02\x10\x03J\x04\b\x04\x10\x05J\x04\b\x05\x10\x06\"q\n" + + "\aLogFile\x12?\n" + + "\x06digest\x18\x01 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x06digest\x12%\n" + + "\x0ehuman_readable\x18\x02 \x01(\bR\rhumanReadable\"\x8f\x03\n" + + "\x0fExecuteResponse\x12E\n" + + "\x06result\x18\x01 \x01(\v2-.build.bazel.remote.execution.v2.ActionResultR\x06result\x12#\n" + + "\rcached_result\x18\x02 \x01(\bR\fcachedResult\x12*\n" + + "\x06status\x18\x03 \x01(\v2\x12.google.rpc.StatusR\x06status\x12a\n" + + "\vserver_logs\x18\x04 \x03(\v2@.build.bazel.remote.execution.v2.ExecuteResponse.ServerLogsEntryR\n" + + "serverLogs\x12\x18\n" + + "\amessage\x18\x05 \x01(\tR\amessage\x1ag\n" + + "\x0fServerLogsEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12>\n" + + "\x05value\x18\x02 \x01(\v2(.build.bazel.remote.execution.v2.LogFileR\x05value:\x028\x01\"a\n" + + "\x0eExecutionStage\"O\n" + + "\x05Value\x12\v\n" + + "\aUNKNOWN\x10\x00\x12\x0f\n" + + "\vCACHE_CHECK\x10\x01\x12\n" + + "\n" + + "\x06QUEUED\x10\x02\x12\r\n" + + "\tEXECUTING\x10\x03\x12\r\n" + + "\tCOMPLETED\x10\x04\"\xe8\x03\n" + + "\x18ExecuteOperationMetadata\x12K\n" + + "\x05stage\x18\x01 \x01(\x0e25.build.bazel.remote.execution.v2.ExecutionStage.ValueR\x05stage\x12L\n" + + "\raction_digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\factionDigest\x12,\n" + + "\x12stdout_stream_name\x18\x03 \x01(\tR\x10stdoutStreamName\x12,\n" + + "\x12stderr_stream_name\x18\x04 \x01(\tR\x10stderrStreamName\x12u\n" + + "\x1apartial_execution_metadata\x18\x05 \x01(\v27.build.bazel.remote.execution.v2.ExecutedActionMetadataR\x18partialExecutionMetadata\x12^\n" + + "\x0fdigest_function\x18\x06 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\"*\n" + + "\x14WaitExecutionRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"\xe5\x02\n" + + "\x16GetActionResultRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12L\n" + + "\raction_digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\factionDigest\x12#\n" + + "\rinline_stdout\x18\x03 \x01(\bR\finlineStdout\x12#\n" + + "\rinline_stderr\x18\x04 \x01(\bR\finlineStderr\x12.\n" + + "\x13inline_output_files\x18\x05 \x03(\tR\x11inlineOutputFiles\x12^\n" + + "\x0fdigest_function\x18\x06 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\"\xa9\x03\n" + + "\x19UpdateActionResultRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12L\n" + + "\raction_digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\factionDigest\x12R\n" + + "\raction_result\x18\x03 \x01(\v2-.build.bazel.remote.execution.v2.ActionResultR\factionResult\x12e\n" + + "\x14results_cache_policy\x18\x04 \x01(\v23.build.bazel.remote.execution.v2.ResultsCachePolicyR\x12resultsCachePolicy\x12^\n" + + "\x0fdigest_function\x18\x05 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\"\xea\x01\n" + + "\x17FindMissingBlobsRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12J\n" + + "\fblob_digests\x18\x02 \x03(\v2'.build.bazel.remote.execution.v2.DigestR\vblobDigests\x12^\n" + + "\x0fdigest_function\x18\x03 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\"u\n" + + "\x18FindMissingBlobsResponse\x12Y\n" + + "\x14missing_blob_digests\x18\x02 \x03(\v2'.build.bazel.remote.execution.v2.DigestR\x12missingBlobDigests\"\xb0\x03\n" + + "\x17BatchUpdateBlobsRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12\\\n" + + "\brequests\x18\x02 \x03(\v2@.build.bazel.remote.execution.v2.BatchUpdateBlobsRequest.RequestR\brequests\x12^\n" + + "\x0fdigest_function\x18\x05 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\x1a\xb1\x01\n" + + "\aRequest\x12?\n" + + "\x06digest\x18\x01 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x06digest\x12\x12\n" + + "\x04data\x18\x02 \x01(\fR\x04data\x12Q\n" + + "\n" + + "compressor\x18\x03 \x01(\x0e21.build.bazel.remote.execution.v2.Compressor.ValueR\n" + + "compressor\"\xf5\x01\n" + + "\x18BatchUpdateBlobsResponse\x12`\n" + + "\tresponses\x18\x01 \x03(\v2B.build.bazel.remote.execution.v2.BatchUpdateBlobsResponse.ResponseR\tresponses\x1aw\n" + + "\bResponse\x12?\n" + + "\x06digest\x18\x01 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x06digest\x12*\n" + + "\x06status\x18\x02 \x01(\v2\x12.google.rpc.StatusR\x06status\"\xc9\x02\n" + + "\x15BatchReadBlobsRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12A\n" + + "\adigests\x18\x02 \x03(\v2'.build.bazel.remote.execution.v2.DigestR\adigests\x12h\n" + + "\x16acceptable_compressors\x18\x03 \x03(\x0e21.build.bazel.remote.execution.v2.Compressor.ValueR\x15acceptableCompressors\x12^\n" + + "\x0fdigest_function\x18\x04 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\"\xd9\x02\n" + + "\x16BatchReadBlobsResponse\x12^\n" + + "\tresponses\x18\x01 \x03(\v2@.build.bazel.remote.execution.v2.BatchReadBlobsResponse.ResponseR\tresponses\x1a\xde\x01\n" + + "\bResponse\x12?\n" + + "\x06digest\x18\x01 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\x06digest\x12\x12\n" + + "\x04data\x18\x02 \x01(\fR\x04data\x12Q\n" + + "\n" + + "compressor\x18\x04 \x01(\x0e21.build.bazel.remote.execution.v2.Compressor.ValueR\n" + + "compressor\x12*\n" + + "\x06status\x18\x03 \x01(\v2\x12.google.rpc.StatusR\x06status\"\x9b\x02\n" + + "\x0eGetTreeRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12H\n" + + "\vroot_digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\n" + + "rootDigest\x12\x1b\n" + + "\tpage_size\x18\x03 \x01(\x05R\bpageSize\x12\x1d\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\tpageToken\x12^\n" + + "\x0fdigest_function\x18\x05 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\"\x87\x01\n" + + "\x0fGetTreeResponse\x12L\n" + + "\vdirectories\x18\x01 \x03(\v2*.build.bazel.remote.execution.v2.DirectoryR\vdirectories\x12&\n" + + "\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken\"\xc7\x02\n" + + "\x10SplitBlobRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12H\n" + + "\vblob_digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\n" + + "blobDigest\x12^\n" + + "\x0fdigest_function\x18\x03 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\x12d\n" + + "\x11chunking_function\x18\x04 \x01(\x0e27.build.bazel.remote.execution.v2.ChunkingFunction.ValueR\x10chunkingFunction\"\xc7\x01\n" + + "\x11SplitBlobResponse\x12L\n" + + "\rchunk_digests\x18\x01 \x03(\v2'.build.bazel.remote.execution.v2.DigestR\fchunkDigests\x12d\n" + + "\x11chunking_function\x18\x02 \x01(\x0e27.build.bazel.remote.execution.v2.ChunkingFunction.ValueR\x10chunkingFunction\"\x96\x03\n" + + "\x11SpliceBlobRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\x12H\n" + + "\vblob_digest\x18\x02 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\n" + + "blobDigest\x12L\n" + + "\rchunk_digests\x18\x03 \x03(\v2'.build.bazel.remote.execution.v2.DigestR\fchunkDigests\x12^\n" + + "\x0fdigest_function\x18\x04 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\x12d\n" + + "\x11chunking_function\x18\x05 \x01(\x0e27.build.bazel.remote.execution.v2.ChunkingFunction.ValueR\x10chunkingFunction\"^\n" + + "\x12SpliceBlobResponse\x12H\n" + + "\vblob_digest\x18\x01 \x01(\v2'.build.bazel.remote.execution.v2.DigestR\n" + + "blobDigest\"=\n" + + "\x16GetCapabilitiesRequest\x12#\n" + + "\rinstance_name\x18\x01 \x01(\tR\finstanceName\"\xc2\x03\n" + + "\x12ServerCapabilities\x12a\n" + + "\x12cache_capabilities\x18\x01 \x01(\v22.build.bazel.remote.execution.v2.CacheCapabilitiesR\x11cacheCapabilities\x12m\n" + + "\x16execution_capabilities\x18\x02 \x01(\v26.build.bazel.remote.execution.v2.ExecutionCapabilitiesR\x15executionCapabilities\x12P\n" + + "\x16deprecated_api_version\x18\x03 \x01(\v2\x1a.build.bazel.semver.SemVerR\x14deprecatedApiVersion\x12B\n" + + "\x0flow_api_version\x18\x04 \x01(\v2\x1a.build.bazel.semver.SemVerR\rlowApiVersion\x12D\n" + + "\x10high_api_version\x18\x05 \x01(\v2\x1a.build.bazel.semver.SemVerR\x0ehighApiVersion\"\x9d\x01\n" + + "\x0eDigestFunction\"\x8a\x01\n" + + "\x05Value\x12\v\n" + + "\aUNKNOWN\x10\x00\x12\n" + + "\n" + + "\x06SHA256\x10\x01\x12\b\n" + + "\x04SHA1\x10\x02\x12\a\n" + + "\x03MD5\x10\x03\x12\a\n" + + "\x03VSO\x10\x04\x12\n" + + "\n" + + "\x06SHA384\x10\x05\x12\n" + + "\n" + + "\x06SHA512\x10\x06\x12\v\n" + + "\aMURMUR3\x10\a\x12\x0e\n" + + "\n" + + "SHA256TREE\x10\b\x12\n" + + "\n" + + "\x06BLAKE3\x10\t\x12\v\n" + + "\aGITSHA1\x10\n" + + "\"L\n" + + "\x10ChunkingFunction\"8\n" + + "\x05Value\x12\v\n" + + "\aUNKNOWN\x10\x00\x12\x11\n" + + "\rFAST_CDC_2020\x10\x01\x12\x0f\n" + + "\vREP_MAX_CDC\x10\x02\"F\n" + + "\x1dActionCacheUpdateCapabilities\x12%\n" + + "\x0eupdate_enabled\x18\x01 \x01(\bR\rupdateEnabled\"\xd2\x01\n" + + "\x14PriorityCapabilities\x12c\n" + + "\n" + + "priorities\x18\x01 \x03(\v2C.build.bazel.remote.execution.v2.PriorityCapabilities.PriorityRangeR\n" + + "priorities\x1aU\n" + + "\rPriorityRange\x12!\n" + + "\fmin_priority\x18\x01 \x01(\x05R\vminPriority\x12!\n" + + "\fmax_priority\x18\x02 \x01(\x05R\vmaxPriority\"P\n" + + "\x1bSymlinkAbsolutePathStrategy\"1\n" + + "\x05Value\x12\v\n" + + "\aUNKNOWN\x10\x00\x12\x0e\n" + + "\n" + + "DISALLOWED\x10\x01\x12\v\n" + + "\aALLOWED\x10\x02\"F\n" + + "\n" + + "Compressor\"8\n" + + "\x05Value\x12\f\n" + + "\bIDENTITY\x10\x00\x12\b\n" + + "\x04ZSTD\x10\x01\x12\v\n" + + "\aDEFLATE\x10\x02\x12\n" + + "\n" + + "\x06BROTLI\x10\x03\"\xfc\b\n" + + "\x11CacheCapabilities\x12`\n" + + "\x10digest_functions\x18\x01 \x03(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0fdigestFunctions\x12\x87\x01\n" + + " action_cache_update_capabilities\x18\x02 \x01(\v2>.build.bazel.remote.execution.v2.ActionCacheUpdateCapabilitiesR\x1dactionCacheUpdateCapabilities\x12u\n" + + "\x1bcache_priority_capabilities\x18\x03 \x01(\v25.build.bazel.remote.execution.v2.PriorityCapabilitiesR\x19cachePriorityCapabilities\x12:\n" + + "\x1amax_batch_total_size_bytes\x18\x04 \x01(\x03R\x16maxBatchTotalSizeBytes\x12\x87\x01\n" + + "\x1esymlink_absolute_path_strategy\x18\x05 \x01(\x0e2B.build.bazel.remote.execution.v2.SymlinkAbsolutePathStrategy.ValueR\x1bsymlinkAbsolutePathStrategy\x12f\n" + + "\x15supported_compressors\x18\x06 \x03(\x0e21.build.bazel.remote.execution.v2.Compressor.ValueR\x14supportedCompressors\x12~\n" + + "\"supported_batch_update_compressors\x18\a \x03(\x0e21.build.bazel.remote.execution.v2.Compressor.ValueR\x1fsupportedBatchUpdateCompressors\x124\n" + + "\x17max_cas_blob_size_bytes\x18\b \x01(\x03R\x13maxCasBlobSizeBytes\x12,\n" + + "\x12split_blob_support\x18\t \x01(\bR\x10splitBlobSupport\x12.\n" + + "\x13splice_blob_support\x18\n" + + " \x01(\bR\x11spliceBlobSupport\x12c\n" + + "\x14fast_cdc_2020_params\x18\v \x01(\v22.build.bazel.remote.execution.v2.FastCdc2020ParamsR\x11fastCdc2020Params\x12]\n" + + "\x12rep_max_cdc_params\x18\f \x01(\v20.build.bazel.remote.execution.v2.RepMaxCdcParamsR\x0frepMaxCdcParams\"X\n" + + "\x11FastCdc2020Params\x12/\n" + + "\x14avg_chunk_size_bytes\x18\x01 \x01(\x04R\x11avgChunkSizeBytes\x12\x12\n" + + "\x04seed\x18\x02 \x01(\rR\x04seed\"p\n" + + "\x0fRepMaxCdcParams\x12/\n" + + "\x14min_chunk_size_bytes\x18\x01 \x01(\x04R\x11minChunkSizeBytes\x12,\n" + + "\x12horizon_size_bytes\x18\x02 \x01(\x04R\x10horizonSizeBytes\"\xb7\x03\n" + + "\x15ExecutionCapabilities\x12^\n" + + "\x0fdigest_function\x18\x01 \x01(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0edigestFunction\x12!\n" + + "\fexec_enabled\x18\x02 \x01(\bR\vexecEnabled\x12}\n" + + "\x1fexecution_priority_capabilities\x18\x03 \x01(\v25.build.bazel.remote.execution.v2.PriorityCapabilitiesR\x1dexecutionPriorityCapabilities\x12:\n" + + "\x19supported_node_properties\x18\x04 \x03(\tR\x17supportedNodeProperties\x12`\n" + + "\x10digest_functions\x18\x05 \x03(\x0e25.build.bazel.remote.execution.v2.DigestFunction.ValueR\x0fdigestFunctions\"M\n" + + "\vToolDetails\x12\x1b\n" + + "\ttool_name\x18\x01 \x01(\tR\btoolName\x12!\n" + + "\ftool_version\x18\x02 \x01(\tR\vtoolVersion\"\xda\x02\n" + + "\x0fRequestMetadata\x12O\n" + + "\ftool_details\x18\x01 \x01(\v2,.build.bazel.remote.execution.v2.ToolDetailsR\vtoolDetails\x12\x1b\n" + + "\taction_id\x18\x02 \x01(\tR\bactionId\x12,\n" + + "\x12tool_invocation_id\x18\x03 \x01(\tR\x10toolInvocationId\x12:\n" + + "\x19correlated_invocations_id\x18\x04 \x01(\tR\x17correlatedInvocationsId\x12'\n" + + "\x0faction_mnemonic\x18\x05 \x01(\tR\x0eactionMnemonic\x12\x1b\n" + + "\ttarget_id\x18\x06 \x01(\tR\btargetId\x12)\n" + + "\x10configuration_id\x18\a \x01(\tR\x0fconfigurationId2\xb9\x02\n" + + "\tExecution\x12\x8e\x01\n" + + "\aExecute\x12/.build.bazel.remote.execution.v2.ExecuteRequest\x1a\x1d.google.longrunning.Operation\"1\x82\xd3\xe4\x93\x02+:\x01*\"&/v2/{instance_name=**}/actions:execute0\x01\x12\x9a\x01\n" + + "\rWaitExecution\x125.build.bazel.remote.execution.v2.WaitExecutionRequest\x1a\x1d.google.longrunning.Operation\"1\x82\xd3\xe4\x93\x02+:\x01*\"&/v2/{name=operations/**}:waitExecution0\x012\xd6\x03\n" + + "\vActionCache\x12\xd7\x01\n" + + "\x0fGetActionResult\x127.build.bazel.remote.execution.v2.GetActionResultRequest\x1a-.build.bazel.remote.execution.v2.ActionResult\"\\\x82\xd3\xe4\x93\x02V\x12T/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}\x12\xec\x01\n" + + "\x12UpdateActionResult\x12:.build.bazel.remote.execution.v2.UpdateActionResultRequest\x1a-.build.bazel.remote.execution.v2.ActionResult\"k\x82\xd3\xe4\x93\x02e:\raction_result\x1aT/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}2\x98\t\n" + + "\x19ContentAddressableStorage\x12\xbc\x01\n" + + "\x10FindMissingBlobs\x128.build.bazel.remote.execution.v2.FindMissingBlobsRequest\x1a9.build.bazel.remote.execution.v2.FindMissingBlobsResponse\"3\x82\xd3\xe4\x93\x02-:\x01*\"(/v2/{instance_name=**}/blobs:findMissing\x12\xbc\x01\n" + + "\x10BatchUpdateBlobs\x128.build.bazel.remote.execution.v2.BatchUpdateBlobsRequest\x1a9.build.bazel.remote.execution.v2.BatchUpdateBlobsResponse\"3\x82\xd3\xe4\x93\x02-:\x01*\"(/v2/{instance_name=**}/blobs:batchUpdate\x12\xb4\x01\n" + + "\x0eBatchReadBlobs\x126.build.bazel.remote.execution.v2.BatchReadBlobsRequest\x1a7.build.bazel.remote.execution.v2.BatchReadBlobsResponse\"1\x82\xd3\xe4\x93\x02+:\x01*\"&/v2/{instance_name=**}/blobs:batchRead\x12\xc8\x01\n" + + "\aGetTree\x12/.build.bazel.remote.execution.v2.GetTreeRequest\x1a0.build.bazel.remote.execution.v2.GetTreeResponse\"X\x82\xd3\xe4\x93\x02R\x12P/v2/{instance_name=**}/blobs/{root_digest.hash}/{root_digest.size_bytes}:getTree0\x01\x12\xce\x01\n" + + "\tSplitBlob\x121.build.bazel.remote.execution.v2.SplitBlobRequest\x1a2.build.bazel.remote.execution.v2.SplitBlobResponse\"Z\x82\xd3\xe4\x93\x02T\x12R/v2/{instance_name=**}/blobs/{blob_digest.hash}/{blob_digest.size_bytes}:splitBlob\x12\xa9\x01\n" + + "\n" + + "SpliceBlob\x122.build.bazel.remote.execution.v2.SpliceBlobRequest\x1a3.build.bazel.remote.execution.v2.SpliceBlobResponse\"2\x82\xd3\xe4\x93\x02,:\x01*\"'/v2/{instance_name=**}/blobs:spliceBlob2\xbd\x01\n" + + "\fCapabilities\x12\xac\x01\n" + + "\x0fGetCapabilities\x127.build.bazel.remote.execution.v2.GetCapabilitiesRequest\x1a3.build.bazel.remote.execution.v2.ServerCapabilities\"+\x82\xd3\xe4\x93\x02%\x12#/v2/{instance_name=**}/capabilitiesB\xb4\x01\n" + + "\x1fbuild.bazel.remote.execution.v2B\x14RemoteExecutionProtoP\x01ZQgithub.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2;remoteexecution\xa2\x02\x03REX\xaa\x02\x1fBuild.Bazel.Remote.Execution.V2b\x06proto3" + +var file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes = make([]protoimpl.EnumInfo, 6) +var file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes = make([]protoimpl.MessageInfo, 59) +var file_build_bazel_remote_execution_v2_remote_execution_proto_goTypes = []any{ + (Command_OutputDirectoryFormat)(0), // 0: build.bazel.remote.execution.v2.Command.OutputDirectoryFormat + (ExecutionStage_Value)(0), // 1: build.bazel.remote.execution.v2.ExecutionStage.Value + (DigestFunction_Value)(0), // 2: build.bazel.remote.execution.v2.DigestFunction.Value + (ChunkingFunction_Value)(0), // 3: build.bazel.remote.execution.v2.ChunkingFunction.Value + (SymlinkAbsolutePathStrategy_Value)(0), // 4: build.bazel.remote.execution.v2.SymlinkAbsolutePathStrategy.Value + (Compressor_Value)(0), // 5: build.bazel.remote.execution.v2.Compressor.Value + (*Action)(nil), // 6: build.bazel.remote.execution.v2.Action + (*Command)(nil), // 7: build.bazel.remote.execution.v2.Command + (*Platform)(nil), // 8: build.bazel.remote.execution.v2.Platform + (*Directory)(nil), // 9: build.bazel.remote.execution.v2.Directory + (*NodeProperty)(nil), // 10: build.bazel.remote.execution.v2.NodeProperty + (*NodeProperties)(nil), // 11: build.bazel.remote.execution.v2.NodeProperties + (*FileNode)(nil), // 12: build.bazel.remote.execution.v2.FileNode + (*DirectoryNode)(nil), // 13: build.bazel.remote.execution.v2.DirectoryNode + (*SymlinkNode)(nil), // 14: build.bazel.remote.execution.v2.SymlinkNode + (*Digest)(nil), // 15: build.bazel.remote.execution.v2.Digest + (*ExecutedActionMetadata)(nil), // 16: build.bazel.remote.execution.v2.ExecutedActionMetadata + (*ActionResult)(nil), // 17: build.bazel.remote.execution.v2.ActionResult + (*OutputFile)(nil), // 18: build.bazel.remote.execution.v2.OutputFile + (*Tree)(nil), // 19: build.bazel.remote.execution.v2.Tree + (*OutputDirectory)(nil), // 20: build.bazel.remote.execution.v2.OutputDirectory + (*OutputSymlink)(nil), // 21: build.bazel.remote.execution.v2.OutputSymlink + (*ExecutionPolicy)(nil), // 22: build.bazel.remote.execution.v2.ExecutionPolicy + (*ResultsCachePolicy)(nil), // 23: build.bazel.remote.execution.v2.ResultsCachePolicy + (*ExecuteRequest)(nil), // 24: build.bazel.remote.execution.v2.ExecuteRequest + (*LogFile)(nil), // 25: build.bazel.remote.execution.v2.LogFile + (*ExecuteResponse)(nil), // 26: build.bazel.remote.execution.v2.ExecuteResponse + (*ExecutionStage)(nil), // 27: build.bazel.remote.execution.v2.ExecutionStage + (*ExecuteOperationMetadata)(nil), // 28: build.bazel.remote.execution.v2.ExecuteOperationMetadata + (*WaitExecutionRequest)(nil), // 29: build.bazel.remote.execution.v2.WaitExecutionRequest + (*GetActionResultRequest)(nil), // 30: build.bazel.remote.execution.v2.GetActionResultRequest + (*UpdateActionResultRequest)(nil), // 31: build.bazel.remote.execution.v2.UpdateActionResultRequest + (*FindMissingBlobsRequest)(nil), // 32: build.bazel.remote.execution.v2.FindMissingBlobsRequest + (*FindMissingBlobsResponse)(nil), // 33: build.bazel.remote.execution.v2.FindMissingBlobsResponse + (*BatchUpdateBlobsRequest)(nil), // 34: build.bazel.remote.execution.v2.BatchUpdateBlobsRequest + (*BatchUpdateBlobsResponse)(nil), // 35: build.bazel.remote.execution.v2.BatchUpdateBlobsResponse + (*BatchReadBlobsRequest)(nil), // 36: build.bazel.remote.execution.v2.BatchReadBlobsRequest + (*BatchReadBlobsResponse)(nil), // 37: build.bazel.remote.execution.v2.BatchReadBlobsResponse + (*GetTreeRequest)(nil), // 38: build.bazel.remote.execution.v2.GetTreeRequest + (*GetTreeResponse)(nil), // 39: build.bazel.remote.execution.v2.GetTreeResponse + (*SplitBlobRequest)(nil), // 40: build.bazel.remote.execution.v2.SplitBlobRequest + (*SplitBlobResponse)(nil), // 41: build.bazel.remote.execution.v2.SplitBlobResponse + (*SpliceBlobRequest)(nil), // 42: build.bazel.remote.execution.v2.SpliceBlobRequest + (*SpliceBlobResponse)(nil), // 43: build.bazel.remote.execution.v2.SpliceBlobResponse + (*GetCapabilitiesRequest)(nil), // 44: build.bazel.remote.execution.v2.GetCapabilitiesRequest + (*ServerCapabilities)(nil), // 45: build.bazel.remote.execution.v2.ServerCapabilities + (*DigestFunction)(nil), // 46: build.bazel.remote.execution.v2.DigestFunction + (*ChunkingFunction)(nil), // 47: build.bazel.remote.execution.v2.ChunkingFunction + (*ActionCacheUpdateCapabilities)(nil), // 48: build.bazel.remote.execution.v2.ActionCacheUpdateCapabilities + (*PriorityCapabilities)(nil), // 49: build.bazel.remote.execution.v2.PriorityCapabilities + (*SymlinkAbsolutePathStrategy)(nil), // 50: build.bazel.remote.execution.v2.SymlinkAbsolutePathStrategy + (*Compressor)(nil), // 51: build.bazel.remote.execution.v2.Compressor + (*CacheCapabilities)(nil), // 52: build.bazel.remote.execution.v2.CacheCapabilities + (*FastCdc2020Params)(nil), // 53: build.bazel.remote.execution.v2.FastCdc2020Params + (*RepMaxCdcParams)(nil), // 54: build.bazel.remote.execution.v2.RepMaxCdcParams + (*ExecutionCapabilities)(nil), // 55: build.bazel.remote.execution.v2.ExecutionCapabilities + (*ToolDetails)(nil), // 56: build.bazel.remote.execution.v2.ToolDetails + (*RequestMetadata)(nil), // 57: build.bazel.remote.execution.v2.RequestMetadata + (*Command_EnvironmentVariable)(nil), // 58: build.bazel.remote.execution.v2.Command.EnvironmentVariable + (*Platform_Property)(nil), // 59: build.bazel.remote.execution.v2.Platform.Property + nil, // 60: build.bazel.remote.execution.v2.ExecuteResponse.ServerLogsEntry + (*BatchUpdateBlobsRequest_Request)(nil), // 61: build.bazel.remote.execution.v2.BatchUpdateBlobsRequest.Request + (*BatchUpdateBlobsResponse_Response)(nil), // 62: build.bazel.remote.execution.v2.BatchUpdateBlobsResponse.Response + (*BatchReadBlobsResponse_Response)(nil), // 63: build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response + (*PriorityCapabilities_PriorityRange)(nil), // 64: build.bazel.remote.execution.v2.PriorityCapabilities.PriorityRange + (*durationpb.Duration)(nil), // 65: google.protobuf.Duration + (*timestamppb.Timestamp)(nil), // 66: google.protobuf.Timestamp + (*wrapperspb.UInt32Value)(nil), // 67: google.protobuf.UInt32Value + (*anypb.Any)(nil), // 68: google.protobuf.Any + (*status.Status)(nil), // 69: google.rpc.Status + (*semver.SemVer)(nil), // 70: build.bazel.semver.SemVer + (*longrunningpb.Operation)(nil), // 71: google.longrunning.Operation +} +var file_build_bazel_remote_execution_v2_remote_execution_proto_depIdxs = []int32{ + 15, // 0: build.bazel.remote.execution.v2.Action.command_digest:type_name -> build.bazel.remote.execution.v2.Digest + 15, // 1: build.bazel.remote.execution.v2.Action.input_root_digest:type_name -> build.bazel.remote.execution.v2.Digest + 65, // 2: build.bazel.remote.execution.v2.Action.timeout:type_name -> google.protobuf.Duration + 8, // 3: build.bazel.remote.execution.v2.Action.platform:type_name -> build.bazel.remote.execution.v2.Platform + 58, // 4: build.bazel.remote.execution.v2.Command.environment_variables:type_name -> build.bazel.remote.execution.v2.Command.EnvironmentVariable + 8, // 5: build.bazel.remote.execution.v2.Command.platform:type_name -> build.bazel.remote.execution.v2.Platform + 0, // 6: build.bazel.remote.execution.v2.Command.output_directory_format:type_name -> build.bazel.remote.execution.v2.Command.OutputDirectoryFormat + 59, // 7: build.bazel.remote.execution.v2.Platform.properties:type_name -> build.bazel.remote.execution.v2.Platform.Property + 12, // 8: build.bazel.remote.execution.v2.Directory.files:type_name -> build.bazel.remote.execution.v2.FileNode + 13, // 9: build.bazel.remote.execution.v2.Directory.directories:type_name -> build.bazel.remote.execution.v2.DirectoryNode + 14, // 10: build.bazel.remote.execution.v2.Directory.symlinks:type_name -> build.bazel.remote.execution.v2.SymlinkNode + 11, // 11: build.bazel.remote.execution.v2.Directory.node_properties:type_name -> build.bazel.remote.execution.v2.NodeProperties + 10, // 12: build.bazel.remote.execution.v2.NodeProperties.properties:type_name -> build.bazel.remote.execution.v2.NodeProperty + 66, // 13: build.bazel.remote.execution.v2.NodeProperties.mtime:type_name -> google.protobuf.Timestamp + 67, // 14: build.bazel.remote.execution.v2.NodeProperties.unix_mode:type_name -> google.protobuf.UInt32Value + 15, // 15: build.bazel.remote.execution.v2.FileNode.digest:type_name -> build.bazel.remote.execution.v2.Digest + 11, // 16: build.bazel.remote.execution.v2.FileNode.node_properties:type_name -> build.bazel.remote.execution.v2.NodeProperties + 15, // 17: build.bazel.remote.execution.v2.DirectoryNode.digest:type_name -> build.bazel.remote.execution.v2.Digest + 11, // 18: build.bazel.remote.execution.v2.SymlinkNode.node_properties:type_name -> build.bazel.remote.execution.v2.NodeProperties + 66, // 19: build.bazel.remote.execution.v2.ExecutedActionMetadata.queued_timestamp:type_name -> google.protobuf.Timestamp + 66, // 20: build.bazel.remote.execution.v2.ExecutedActionMetadata.worker_start_timestamp:type_name -> google.protobuf.Timestamp + 66, // 21: build.bazel.remote.execution.v2.ExecutedActionMetadata.worker_completed_timestamp:type_name -> google.protobuf.Timestamp + 66, // 22: build.bazel.remote.execution.v2.ExecutedActionMetadata.input_fetch_start_timestamp:type_name -> google.protobuf.Timestamp + 66, // 23: build.bazel.remote.execution.v2.ExecutedActionMetadata.input_fetch_completed_timestamp:type_name -> google.protobuf.Timestamp + 66, // 24: build.bazel.remote.execution.v2.ExecutedActionMetadata.execution_start_timestamp:type_name -> google.protobuf.Timestamp + 66, // 25: build.bazel.remote.execution.v2.ExecutedActionMetadata.execution_completed_timestamp:type_name -> google.protobuf.Timestamp + 65, // 26: build.bazel.remote.execution.v2.ExecutedActionMetadata.virtual_execution_duration:type_name -> google.protobuf.Duration + 66, // 27: build.bazel.remote.execution.v2.ExecutedActionMetadata.output_upload_start_timestamp:type_name -> google.protobuf.Timestamp + 66, // 28: build.bazel.remote.execution.v2.ExecutedActionMetadata.output_upload_completed_timestamp:type_name -> google.protobuf.Timestamp + 68, // 29: build.bazel.remote.execution.v2.ExecutedActionMetadata.auxiliary_metadata:type_name -> google.protobuf.Any + 18, // 30: build.bazel.remote.execution.v2.ActionResult.output_files:type_name -> build.bazel.remote.execution.v2.OutputFile + 21, // 31: build.bazel.remote.execution.v2.ActionResult.output_file_symlinks:type_name -> build.bazel.remote.execution.v2.OutputSymlink + 21, // 32: build.bazel.remote.execution.v2.ActionResult.output_symlinks:type_name -> build.bazel.remote.execution.v2.OutputSymlink + 20, // 33: build.bazel.remote.execution.v2.ActionResult.output_directories:type_name -> build.bazel.remote.execution.v2.OutputDirectory + 21, // 34: build.bazel.remote.execution.v2.ActionResult.output_directory_symlinks:type_name -> build.bazel.remote.execution.v2.OutputSymlink + 15, // 35: build.bazel.remote.execution.v2.ActionResult.stdout_digest:type_name -> build.bazel.remote.execution.v2.Digest + 15, // 36: build.bazel.remote.execution.v2.ActionResult.stderr_digest:type_name -> build.bazel.remote.execution.v2.Digest + 16, // 37: build.bazel.remote.execution.v2.ActionResult.execution_metadata:type_name -> build.bazel.remote.execution.v2.ExecutedActionMetadata + 15, // 38: build.bazel.remote.execution.v2.OutputFile.digest:type_name -> build.bazel.remote.execution.v2.Digest + 11, // 39: build.bazel.remote.execution.v2.OutputFile.node_properties:type_name -> build.bazel.remote.execution.v2.NodeProperties + 9, // 40: build.bazel.remote.execution.v2.Tree.root:type_name -> build.bazel.remote.execution.v2.Directory + 9, // 41: build.bazel.remote.execution.v2.Tree.children:type_name -> build.bazel.remote.execution.v2.Directory + 15, // 42: build.bazel.remote.execution.v2.OutputDirectory.tree_digest:type_name -> build.bazel.remote.execution.v2.Digest + 15, // 43: build.bazel.remote.execution.v2.OutputDirectory.root_directory_digest:type_name -> build.bazel.remote.execution.v2.Digest + 11, // 44: build.bazel.remote.execution.v2.OutputSymlink.node_properties:type_name -> build.bazel.remote.execution.v2.NodeProperties + 15, // 45: build.bazel.remote.execution.v2.ExecuteRequest.action_digest:type_name -> build.bazel.remote.execution.v2.Digest + 22, // 46: build.bazel.remote.execution.v2.ExecuteRequest.execution_policy:type_name -> build.bazel.remote.execution.v2.ExecutionPolicy + 23, // 47: build.bazel.remote.execution.v2.ExecuteRequest.results_cache_policy:type_name -> build.bazel.remote.execution.v2.ResultsCachePolicy + 2, // 48: build.bazel.remote.execution.v2.ExecuteRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 15, // 49: build.bazel.remote.execution.v2.LogFile.digest:type_name -> build.bazel.remote.execution.v2.Digest + 17, // 50: build.bazel.remote.execution.v2.ExecuteResponse.result:type_name -> build.bazel.remote.execution.v2.ActionResult + 69, // 51: build.bazel.remote.execution.v2.ExecuteResponse.status:type_name -> google.rpc.Status + 60, // 52: build.bazel.remote.execution.v2.ExecuteResponse.server_logs:type_name -> build.bazel.remote.execution.v2.ExecuteResponse.ServerLogsEntry + 1, // 53: build.bazel.remote.execution.v2.ExecuteOperationMetadata.stage:type_name -> build.bazel.remote.execution.v2.ExecutionStage.Value + 15, // 54: build.bazel.remote.execution.v2.ExecuteOperationMetadata.action_digest:type_name -> build.bazel.remote.execution.v2.Digest + 16, // 55: build.bazel.remote.execution.v2.ExecuteOperationMetadata.partial_execution_metadata:type_name -> build.bazel.remote.execution.v2.ExecutedActionMetadata + 2, // 56: build.bazel.remote.execution.v2.ExecuteOperationMetadata.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 15, // 57: build.bazel.remote.execution.v2.GetActionResultRequest.action_digest:type_name -> build.bazel.remote.execution.v2.Digest + 2, // 58: build.bazel.remote.execution.v2.GetActionResultRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 15, // 59: build.bazel.remote.execution.v2.UpdateActionResultRequest.action_digest:type_name -> build.bazel.remote.execution.v2.Digest + 17, // 60: build.bazel.remote.execution.v2.UpdateActionResultRequest.action_result:type_name -> build.bazel.remote.execution.v2.ActionResult + 23, // 61: build.bazel.remote.execution.v2.UpdateActionResultRequest.results_cache_policy:type_name -> build.bazel.remote.execution.v2.ResultsCachePolicy + 2, // 62: build.bazel.remote.execution.v2.UpdateActionResultRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 15, // 63: build.bazel.remote.execution.v2.FindMissingBlobsRequest.blob_digests:type_name -> build.bazel.remote.execution.v2.Digest + 2, // 64: build.bazel.remote.execution.v2.FindMissingBlobsRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 15, // 65: build.bazel.remote.execution.v2.FindMissingBlobsResponse.missing_blob_digests:type_name -> build.bazel.remote.execution.v2.Digest + 61, // 66: build.bazel.remote.execution.v2.BatchUpdateBlobsRequest.requests:type_name -> build.bazel.remote.execution.v2.BatchUpdateBlobsRequest.Request + 2, // 67: build.bazel.remote.execution.v2.BatchUpdateBlobsRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 62, // 68: build.bazel.remote.execution.v2.BatchUpdateBlobsResponse.responses:type_name -> build.bazel.remote.execution.v2.BatchUpdateBlobsResponse.Response + 15, // 69: build.bazel.remote.execution.v2.BatchReadBlobsRequest.digests:type_name -> build.bazel.remote.execution.v2.Digest + 5, // 70: build.bazel.remote.execution.v2.BatchReadBlobsRequest.acceptable_compressors:type_name -> build.bazel.remote.execution.v2.Compressor.Value + 2, // 71: build.bazel.remote.execution.v2.BatchReadBlobsRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 63, // 72: build.bazel.remote.execution.v2.BatchReadBlobsResponse.responses:type_name -> build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response + 15, // 73: build.bazel.remote.execution.v2.GetTreeRequest.root_digest:type_name -> build.bazel.remote.execution.v2.Digest + 2, // 74: build.bazel.remote.execution.v2.GetTreeRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 9, // 75: build.bazel.remote.execution.v2.GetTreeResponse.directories:type_name -> build.bazel.remote.execution.v2.Directory + 15, // 76: build.bazel.remote.execution.v2.SplitBlobRequest.blob_digest:type_name -> build.bazel.remote.execution.v2.Digest + 2, // 77: build.bazel.remote.execution.v2.SplitBlobRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 3, // 78: build.bazel.remote.execution.v2.SplitBlobRequest.chunking_function:type_name -> build.bazel.remote.execution.v2.ChunkingFunction.Value + 15, // 79: build.bazel.remote.execution.v2.SplitBlobResponse.chunk_digests:type_name -> build.bazel.remote.execution.v2.Digest + 3, // 80: build.bazel.remote.execution.v2.SplitBlobResponse.chunking_function:type_name -> build.bazel.remote.execution.v2.ChunkingFunction.Value + 15, // 81: build.bazel.remote.execution.v2.SpliceBlobRequest.blob_digest:type_name -> build.bazel.remote.execution.v2.Digest + 15, // 82: build.bazel.remote.execution.v2.SpliceBlobRequest.chunk_digests:type_name -> build.bazel.remote.execution.v2.Digest + 2, // 83: build.bazel.remote.execution.v2.SpliceBlobRequest.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 3, // 84: build.bazel.remote.execution.v2.SpliceBlobRequest.chunking_function:type_name -> build.bazel.remote.execution.v2.ChunkingFunction.Value + 15, // 85: build.bazel.remote.execution.v2.SpliceBlobResponse.blob_digest:type_name -> build.bazel.remote.execution.v2.Digest + 52, // 86: build.bazel.remote.execution.v2.ServerCapabilities.cache_capabilities:type_name -> build.bazel.remote.execution.v2.CacheCapabilities + 55, // 87: build.bazel.remote.execution.v2.ServerCapabilities.execution_capabilities:type_name -> build.bazel.remote.execution.v2.ExecutionCapabilities + 70, // 88: build.bazel.remote.execution.v2.ServerCapabilities.deprecated_api_version:type_name -> build.bazel.semver.SemVer + 70, // 89: build.bazel.remote.execution.v2.ServerCapabilities.low_api_version:type_name -> build.bazel.semver.SemVer + 70, // 90: build.bazel.remote.execution.v2.ServerCapabilities.high_api_version:type_name -> build.bazel.semver.SemVer + 64, // 91: build.bazel.remote.execution.v2.PriorityCapabilities.priorities:type_name -> build.bazel.remote.execution.v2.PriorityCapabilities.PriorityRange + 2, // 92: build.bazel.remote.execution.v2.CacheCapabilities.digest_functions:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 48, // 93: build.bazel.remote.execution.v2.CacheCapabilities.action_cache_update_capabilities:type_name -> build.bazel.remote.execution.v2.ActionCacheUpdateCapabilities + 49, // 94: build.bazel.remote.execution.v2.CacheCapabilities.cache_priority_capabilities:type_name -> build.bazel.remote.execution.v2.PriorityCapabilities + 4, // 95: build.bazel.remote.execution.v2.CacheCapabilities.symlink_absolute_path_strategy:type_name -> build.bazel.remote.execution.v2.SymlinkAbsolutePathStrategy.Value + 5, // 96: build.bazel.remote.execution.v2.CacheCapabilities.supported_compressors:type_name -> build.bazel.remote.execution.v2.Compressor.Value + 5, // 97: build.bazel.remote.execution.v2.CacheCapabilities.supported_batch_update_compressors:type_name -> build.bazel.remote.execution.v2.Compressor.Value + 53, // 98: build.bazel.remote.execution.v2.CacheCapabilities.fast_cdc_2020_params:type_name -> build.bazel.remote.execution.v2.FastCdc2020Params + 54, // 99: build.bazel.remote.execution.v2.CacheCapabilities.rep_max_cdc_params:type_name -> build.bazel.remote.execution.v2.RepMaxCdcParams + 2, // 100: build.bazel.remote.execution.v2.ExecutionCapabilities.digest_function:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 49, // 101: build.bazel.remote.execution.v2.ExecutionCapabilities.execution_priority_capabilities:type_name -> build.bazel.remote.execution.v2.PriorityCapabilities + 2, // 102: build.bazel.remote.execution.v2.ExecutionCapabilities.digest_functions:type_name -> build.bazel.remote.execution.v2.DigestFunction.Value + 56, // 103: build.bazel.remote.execution.v2.RequestMetadata.tool_details:type_name -> build.bazel.remote.execution.v2.ToolDetails + 25, // 104: build.bazel.remote.execution.v2.ExecuteResponse.ServerLogsEntry.value:type_name -> build.bazel.remote.execution.v2.LogFile + 15, // 105: build.bazel.remote.execution.v2.BatchUpdateBlobsRequest.Request.digest:type_name -> build.bazel.remote.execution.v2.Digest + 5, // 106: build.bazel.remote.execution.v2.BatchUpdateBlobsRequest.Request.compressor:type_name -> build.bazel.remote.execution.v2.Compressor.Value + 15, // 107: build.bazel.remote.execution.v2.BatchUpdateBlobsResponse.Response.digest:type_name -> build.bazel.remote.execution.v2.Digest + 69, // 108: build.bazel.remote.execution.v2.BatchUpdateBlobsResponse.Response.status:type_name -> google.rpc.Status + 15, // 109: build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response.digest:type_name -> build.bazel.remote.execution.v2.Digest + 5, // 110: build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response.compressor:type_name -> build.bazel.remote.execution.v2.Compressor.Value + 69, // 111: build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response.status:type_name -> google.rpc.Status + 24, // 112: build.bazel.remote.execution.v2.Execution.Execute:input_type -> build.bazel.remote.execution.v2.ExecuteRequest + 29, // 113: build.bazel.remote.execution.v2.Execution.WaitExecution:input_type -> build.bazel.remote.execution.v2.WaitExecutionRequest + 30, // 114: build.bazel.remote.execution.v2.ActionCache.GetActionResult:input_type -> build.bazel.remote.execution.v2.GetActionResultRequest + 31, // 115: build.bazel.remote.execution.v2.ActionCache.UpdateActionResult:input_type -> build.bazel.remote.execution.v2.UpdateActionResultRequest + 32, // 116: build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs:input_type -> build.bazel.remote.execution.v2.FindMissingBlobsRequest + 34, // 117: build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs:input_type -> build.bazel.remote.execution.v2.BatchUpdateBlobsRequest + 36, // 118: build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs:input_type -> build.bazel.remote.execution.v2.BatchReadBlobsRequest + 38, // 119: build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree:input_type -> build.bazel.remote.execution.v2.GetTreeRequest + 40, // 120: build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob:input_type -> build.bazel.remote.execution.v2.SplitBlobRequest + 42, // 121: build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob:input_type -> build.bazel.remote.execution.v2.SpliceBlobRequest + 44, // 122: build.bazel.remote.execution.v2.Capabilities.GetCapabilities:input_type -> build.bazel.remote.execution.v2.GetCapabilitiesRequest + 71, // 123: build.bazel.remote.execution.v2.Execution.Execute:output_type -> google.longrunning.Operation + 71, // 124: build.bazel.remote.execution.v2.Execution.WaitExecution:output_type -> google.longrunning.Operation + 17, // 125: build.bazel.remote.execution.v2.ActionCache.GetActionResult:output_type -> build.bazel.remote.execution.v2.ActionResult + 17, // 126: build.bazel.remote.execution.v2.ActionCache.UpdateActionResult:output_type -> build.bazel.remote.execution.v2.ActionResult + 33, // 127: build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs:output_type -> build.bazel.remote.execution.v2.FindMissingBlobsResponse + 35, // 128: build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs:output_type -> build.bazel.remote.execution.v2.BatchUpdateBlobsResponse + 37, // 129: build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs:output_type -> build.bazel.remote.execution.v2.BatchReadBlobsResponse + 39, // 130: build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree:output_type -> build.bazel.remote.execution.v2.GetTreeResponse + 41, // 131: build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob:output_type -> build.bazel.remote.execution.v2.SplitBlobResponse + 43, // 132: build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob:output_type -> build.bazel.remote.execution.v2.SpliceBlobResponse + 45, // 133: build.bazel.remote.execution.v2.Capabilities.GetCapabilities:output_type -> build.bazel.remote.execution.v2.ServerCapabilities + 123, // [123:134] is the sub-list for method output_type + 112, // [112:123] is the sub-list for method input_type + 112, // [112:112] is the sub-list for extension type_name + 112, // [112:112] is the sub-list for extension extendee + 0, // [0:112] is the sub-list for field type_name +} + +func init() { file_build_bazel_remote_execution_v2_remote_execution_proto_init() } +func file_build_bazel_remote_execution_v2_remote_execution_proto_init() { + if File_build_bazel_remote_execution_v2_remote_execution_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_build_bazel_remote_execution_v2_remote_execution_proto_rawDesc), len(file_build_bazel_remote_execution_v2_remote_execution_proto_rawDesc)), + NumEnums: 6, + NumMessages: 59, + NumExtensions: 0, + NumServices: 4, + }, + GoTypes: file_build_bazel_remote_execution_v2_remote_execution_proto_goTypes, + DependencyIndexes: file_build_bazel_remote_execution_v2_remote_execution_proto_depIdxs, + EnumInfos: file_build_bazel_remote_execution_v2_remote_execution_proto_enumTypes, + MessageInfos: file_build_bazel_remote_execution_v2_remote_execution_proto_msgTypes, + }.Build() + File_build_bazel_remote_execution_v2_remote_execution_proto = out.File + file_build_bazel_remote_execution_v2_remote_execution_proto_goTypes = nil + file_build_bazel_remote_execution_v2_remote_execution_proto_depIdxs = nil +} diff --git a/internal/proto/gen/build/bazel/semver/semver.pb.go b/internal/proto/gen/build/bazel/semver/semver.pb.go new file mode 100644 index 0000000..94faa99 --- /dev/null +++ b/internal/proto/gen/build/bazel/semver/semver.pb.go @@ -0,0 +1,191 @@ +// Copyright 2018 The Bazel Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: build/bazel/semver/semver.proto + +package semver + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The full version of a given tool. +type SemVer struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Major int32 `protobuf:"varint,1,opt,name=major,proto3"` + xxx_hidden_Minor int32 `protobuf:"varint,2,opt,name=minor,proto3"` + xxx_hidden_Patch int32 `protobuf:"varint,3,opt,name=patch,proto3"` + xxx_hidden_Prerelease string `protobuf:"bytes,4,opt,name=prerelease,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SemVer) Reset() { + *x = SemVer{} + mi := &file_build_bazel_semver_semver_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SemVer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SemVer) ProtoMessage() {} + +func (x *SemVer) ProtoReflect() protoreflect.Message { + mi := &file_build_bazel_semver_semver_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SemVer) GetMajor() int32 { + if x != nil { + return x.xxx_hidden_Major + } + return 0 +} + +func (x *SemVer) GetMinor() int32 { + if x != nil { + return x.xxx_hidden_Minor + } + return 0 +} + +func (x *SemVer) GetPatch() int32 { + if x != nil { + return x.xxx_hidden_Patch + } + return 0 +} + +func (x *SemVer) GetPrerelease() string { + if x != nil { + return x.xxx_hidden_Prerelease + } + return "" +} + +func (x *SemVer) SetMajor(v int32) { + x.xxx_hidden_Major = v +} + +func (x *SemVer) SetMinor(v int32) { + x.xxx_hidden_Minor = v +} + +func (x *SemVer) SetPatch(v int32) { + x.xxx_hidden_Patch = v +} + +func (x *SemVer) SetPrerelease(v string) { + x.xxx_hidden_Prerelease = v +} + +type SemVer_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The major version, e.g 10 for 10.2.3. + Major int32 + // The minor version, e.g. 2 for 10.2.3. + Minor int32 + // The patch version, e.g 3 for 10.2.3. + Patch int32 + // The pre-release version. Either this field or major/minor/patch fields + // must be filled. They are mutually exclusive. Pre-release versions are + // assumed to be earlier than any released versions. + Prerelease string +} + +func (b0 SemVer_builder) Build() *SemVer { + m0 := &SemVer{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Major = b.Major + x.xxx_hidden_Minor = b.Minor + x.xxx_hidden_Patch = b.Patch + x.xxx_hidden_Prerelease = b.Prerelease + return m0 +} + +var File_build_bazel_semver_semver_proto protoreflect.FileDescriptor + +const file_build_bazel_semver_semver_proto_rawDesc = "" + + "\n" + + "\x1fbuild/bazel/semver/semver.proto\x12\x12build.bazel.semver\"j\n" + + "\x06SemVer\x12\x14\n" + + "\x05major\x18\x01 \x01(\x05R\x05major\x12\x14\n" + + "\x05minor\x18\x02 \x01(\x05R\x05minor\x12\x14\n" + + "\x05patch\x18\x03 \x01(\x05R\x05patch\x12\x1e\n" + + "\n" + + "prerelease\x18\x04 \x01(\tR\n" + + "prereleaseBt\n" + + "\x12build.bazel.semverB\vSemverProtoP\x01Z4github.com/bazelbuild/remote-apis/build/bazel/semver\xa2\x02\x03SMV\xaa\x02\x12Build.Bazel.Semverb\x06proto3" + +var file_build_bazel_semver_semver_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_build_bazel_semver_semver_proto_goTypes = []any{ + (*SemVer)(nil), // 0: build.bazel.semver.SemVer +} +var file_build_bazel_semver_semver_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_build_bazel_semver_semver_proto_init() } +func file_build_bazel_semver_semver_proto_init() { + if File_build_bazel_semver_semver_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_build_bazel_semver_semver_proto_rawDesc), len(file_build_bazel_semver_semver_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_build_bazel_semver_semver_proto_goTypes, + DependencyIndexes: file_build_bazel_semver_semver_proto_depIdxs, + MessageInfos: file_build_bazel_semver_semver_proto_msgTypes, + }.Build() + File_build_bazel_semver_semver_proto = out.File + file_build_bazel_semver_semver_proto_goTypes = nil + file_build_bazel_semver_semver_proto_depIdxs = nil +} diff --git a/internal/server/action_result.go b/internal/server/action_result.go index 3aa80ca..bc22e7c 100644 --- a/internal/server/action_result.go +++ b/internal/server/action_result.go @@ -3,6 +3,10 @@ package server import ( "errors" "fmt" + + "google.golang.org/protobuf/proto" + + remoteexecution "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2" ) const maxActionResultObjects = 100_000 @@ -53,164 +57,98 @@ func newActionResultReferences() actionResultReferences { } func parseActionResult(data []byte) (actionResultReferences, error) { - references := newActionResultReferences() - var stdoutDigest *digestReference - var stderrDigest *digestReference - var stdoutInline bool - var stderrInline bool + message := &remoteexecution.ActionResult{} + if err := proto.Unmarshal(data, message); err != nil { + return actionResultReferences{}, fmt.Errorf("action_result: %w", err) + } - err := visitWireFields(data, func(field wireField) error { - switch field.number { - case 2: - message, err := field.message("action_result.output_files") - if err != nil { - return err - } - digest, inline, err := parseOutputFile(message) - if err != nil { - return err - } - if digest != nil && !inline { - return references.blobs.add(*digest) - } - case 3: - message, err := field.message("action_result.output_directories") - if err != nil { - return err - } - tree, root, err := parseOutputDirectory(message) - if err != nil { - return err - } - if tree != nil { - if err := references.trees.add(*tree); err != nil { - return err - } - } - if root != nil { - if err := references.directories.add(*root); err != nil { - return err - } - } - case 5: - if _, err := field.message("action_result.stdout_raw"); err != nil { - return err - } - stdoutInline = true - case 6: - message, err := field.message("action_result.stdout_digest") - if err != nil { - return err - } - reference, err := parseDigest(message) - if err != nil { - return fmt.Errorf("action_result.stdout_digest: %w", err) - } - stdoutDigest = &reference - case 7: - if _, err := field.message("action_result.stderr_raw"); err != nil { - return err - } - stderrInline = true - case 8: - message, err := field.message("action_result.stderr_digest") - if err != nil { - return err - } - reference, err := parseDigest(message) - if err != nil { - return fmt.Errorf("action_result.stderr_digest: %w", err) - } - stderrDigest = &reference + references := newActionResultReferences() + for _, file := range message.GetOutputFiles() { + if !file.HasDigest() { + if len(file.GetContents()) == 0 { + return actionResultReferences{}, errors.New( + "output_file has neither digest nor inline contents", + ) + } + continue } - return nil - }) - if err != nil { - return actionResultReferences{}, err - } - if stdoutDigest != nil && !stdoutInline { - if err := references.blobs.add(*stdoutDigest); err != nil { + reference, err := digestReferenceFrom(file.GetDigest(), "output_file.digest") + if err != nil { return actionResultReferences{}, err } - } - if stderrDigest != nil && !stderrInline { - if err := references.blobs.add(*stderrDigest); err != nil { + // Inlined contents travel with the action result, so they are not part of + // the CAS closure even though the digest is still declared. + if len(file.GetContents()) > 0 { + continue + } + if err := references.blobs.add(reference); err != nil { return actionResultReferences{}, err } } - return references, nil -} -func parseOutputFile(data []byte) (*digestReference, bool, error) { - var digest *digestReference - var contentsInline bool - err := visitWireFields(data, func(field wireField) error { - switch field.number { - case 2: - message, err := field.message("output_file.digest") - if err != nil { - return err - } - reference, err := parseDigest(message) - if err != nil { - return fmt.Errorf("output_file.digest: %w", err) - } - if digest != nil { - return errors.New("output_file.digest is repeated") - } - digest = &reference - case 5: - if _, err := field.message("output_file.contents"); err != nil { - return err - } - contentsInline = true + for _, directory := range message.GetOutputDirectories() { + if !directory.HasTreeDigest() && !directory.HasRootDirectoryDigest() { + return actionResultReferences{}, errors.New( + "output_directory has no tree or root directory digest", + ) + } + if err := addOutputDigest( + &references.trees, + directory.GetTreeDigest(), + "output_directory.tree_digest", + ); err != nil { + return actionResultReferences{}, err + } + if err := addOutputDigest( + &references.directories, + directory.GetRootDirectoryDigest(), + "output_directory.root_directory_digest", + ); err != nil { + return actionResultReferences{}, err } - return nil - }) - if err != nil { - return nil, false, err - } - if digest == nil && !contentsInline { - return nil, false, errors.New("output_file has neither digest nor inline contents") } - return digest, contentsInline, nil -} -func parseOutputDirectory(data []byte) (*digestReference, *digestReference, error) { - var tree *digestReference - var root *digestReference - err := visitWireFields(data, func(field wireField) error { - var destination **digestReference - var name string - switch field.number { - case 3: - destination = &tree - name = "output_directory.tree_digest" - case 5: - destination = &root - name = "output_directory.root_directory_digest" - default: + addStream := func(digest *remoteexecution.Digest, inline []byte, name string) error { + if digest == nil { return nil } - message, err := field.message(name) + reference, err := digestReferenceFrom(digest, name) if err != nil { return err } - reference, err := parseDigest(message) - if err != nil { - return fmt.Errorf("%s: %w", name, err) - } - if *destination != nil { - return fmt.Errorf("%s is repeated", name) + if len(inline) > 0 { + return nil } - *destination = &reference + return references.blobs.add(reference) + } + if err := addStream( + message.GetStdoutDigest(), + message.GetStdoutRaw(), + "action_result.stdout_digest", + ); err != nil { + return actionResultReferences{}, err + } + if err := addStream( + message.GetStderrDigest(), + message.GetStderrRaw(), + "action_result.stderr_digest", + ); err != nil { + return actionResultReferences{}, err + } + return references, nil +} + +func addOutputDigest( + collection *digestCollection, + digest *remoteexecution.Digest, + name string, +) error { + if digest == nil { return nil - }) - if err != nil { - return nil, nil, err } - if tree == nil && root == nil { - return nil, nil, errors.New("output_directory has no tree or root directory digest") + reference, err := digestReferenceFrom(digest, name) + if err != nil { + return err } - return tree, root, nil + return collection.add(reference) } diff --git a/internal/server/action_result_test.go b/internal/server/action_result_test.go index c756610..0c22926 100644 --- a/internal/server/action_result_test.go +++ b/internal/server/action_result_test.go @@ -8,7 +8,9 @@ import ( "strings" "testing" - "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/proto" + + remoteexecution "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2" ) func TestParseActionResultCollectsOnlyExternalCASReferences(t *testing.T) { @@ -19,14 +21,16 @@ func TestParseActionResultCollectsOnlyExternalCASReferences(t *testing.T) { stdout := referenceFor([]byte("inline stdout")) stderr := referenceFor([]byte("external stderr")) - actionResult := concatProto( - bytesField(2, outputFileProto(direct, nil)), - bytesField(2, outputFileProto(inline, []byte("inline output"))), - bytesField(3, outputDirectoryProto(tree, root)), - bytesField(5, []byte("inline stdout")), - bytesField(6, digestProto(stdout)), - bytesField(8, digestProto(stderr)), - ) + actionResult := marshalProto(t, remoteexecution.ActionResult_builder{ + OutputFiles: []*remoteexecution.OutputFile{ + outputFileProto(direct, nil), + outputFileProto(inline, []byte("inline output")), + }, + OutputDirectories: []*remoteexecution.OutputDirectory{outputDirectoryProto(tree, root)}, + StdoutRaw: []byte("inline stdout"), + StdoutDigest: digestProto(stdout), + StderrDigest: digestProto(stderr), + }.Build()) references, err := parseActionResult(actionResult) if err != nil { @@ -38,11 +42,11 @@ func TestParseActionResultCollectsOnlyExternalCASReferences(t *testing.T) { } func TestParseActionResultRejectsMalformedDigest(t *testing.T) { - malformedDigest := concatProto( - bytesField(1, []byte(strings.Repeat("A", 64))), - varintField(2, 1), - ) - actionResult := bytesField(2, bytesField(2, malformedDigest)) + actionResult := marshalProto(t, remoteexecution.ActionResult_builder{ + OutputFiles: []*remoteexecution.OutputFile{ + outputFileProto(digestReference{hash: strings.Repeat("A", 64), size: 1}, nil), + }, + }.Build()) if _, err := parseActionResult(actionResult); err == nil { t.Fatal("uppercase digest was accepted") } @@ -51,13 +55,18 @@ func TestParseActionResultRejectsMalformedDigest(t *testing.T) { func TestParseTreeCollectsFilesAndRequiresEmbeddedChildren(t *testing.T) { rootFile := referenceFor([]byte("root file")) childFile := referenceFor([]byte("child file")) - child := bytesField(1, fileNodeProto(childFile)) - childReference := referenceFor(child) - root := concatProto( - bytesField(1, fileNodeProto(rootFile)), - bytesField(2, directoryNodeProto(childReference)), - ) - tree := concatProto(bytesField(1, root), bytesField(2, child)) + child := remoteexecution.Directory_builder{ + Files: []*remoteexecution.FileNode{fileNodeProto(childFile)}, + }.Build() + childReference := referenceFor(marshalProto(t, child)) + root := remoteexecution.Directory_builder{ + Files: []*remoteexecution.FileNode{fileNodeProto(rootFile)}, + Directories: []*remoteexecution.DirectoryNode{directoryNodeProto(childReference)}, + }.Build() + tree := marshalProto(t, remoteexecution.Tree_builder{ + Root: root, + Children: []*remoteexecution.Directory{child}, + }.Build()) files, err := parseTree(tree) if err != nil { @@ -65,7 +74,8 @@ func TestParseTreeCollectsFilesAndRequiresEmbeddedChildren(t *testing.T) { } assertReferences(t, files, rootFile, childFile) - if _, err := parseTree(bytesField(1, root)); err == nil { + truncated := marshalProto(t, remoteexecution.Tree_builder{Root: root}.Build()) + if _, err := parseTree(truncated); err == nil { t.Fatal("Tree with a missing embedded child was accepted") } } @@ -73,7 +83,7 @@ func TestParseTreeCollectsFilesAndRequiresEmbeddedChildren(t *testing.T) { func TestActionResultReadRequiresCompleteCASClosure(t *testing.T) { output := []byte("cached output") outputReference := referenceFor(output) - actionResult := bytesField(2, outputFileProto(outputReference, nil)) + actionResult := actionResultProto(t, outputReference) actionDigest := strings.Repeat("a", 64) t.Run("complete", func(t *testing.T) { @@ -112,7 +122,9 @@ func TestActionResultReadRequiresCompleteCASClosure(t *testing.T) { func TestActionResultReadAllowsImplicitEmptyCASDigest(t *testing.T) { emptyReference := referenceFor(nil) - actionResult := bytesField(6, digestProto(emptyReference)) + actionResult := marshalProto(t, remoteexecution.ActionResult_builder{ + StdoutDigest: digestProto(emptyReference), + }.Build()) actionDigest := strings.Repeat("1", 64) backend := newMemoryBackend() backend.objects["test-v1-ac-"+actionDigest] = actionResult @@ -131,9 +143,17 @@ func TestActionResultReadAllowsImplicitEmptyCASDigest(t *testing.T) { func TestActionResultReadValidatesTreeFileClosure(t *testing.T) { fileReference := referenceFor([]byte("missing nested file")) - tree := bytesField(1, bytesField(1, fileNodeProto(fileReference))) + tree := marshalProto(t, remoteexecution.Tree_builder{ + Root: remoteexecution.Directory_builder{ + Files: []*remoteexecution.FileNode{fileNodeProto(fileReference)}, + }.Build(), + }.Build()) treeReference := referenceFor(tree) - actionResult := bytesField(3, outputDirectoryProto(treeReference, digestReference{})) + actionResult := marshalProto(t, remoteexecution.ActionResult_builder{ + OutputDirectories: []*remoteexecution.OutputDirectory{ + outputDirectoryProto(treeReference, digestReference{}), + }, + }.Build()) actionDigest := strings.Repeat("b", 64) backend := newMemoryBackend() @@ -154,11 +174,19 @@ func TestActionResultReadValidatesTreeFileClosure(t *testing.T) { func TestActionResultReadValidatesRootDirectoryClosure(t *testing.T) { file := []byte("nested output") fileReference := referenceFor(file) - child := bytesField(1, fileNodeProto(fileReference)) + child := marshalProto(t, remoteexecution.Directory_builder{ + Files: []*remoteexecution.FileNode{fileNodeProto(fileReference)}, + }.Build()) childReference := referenceFor(child) - root := bytesField(2, directoryNodeProto(childReference)) + root := marshalProto(t, remoteexecution.Directory_builder{ + Directories: []*remoteexecution.DirectoryNode{directoryNodeProto(childReference)}, + }.Build()) rootReference := referenceFor(root) - actionResult := bytesField(3, outputDirectoryProto(digestReference{}, rootReference)) + actionResult := marshalProto(t, remoteexecution.ActionResult_builder{ + OutputDirectories: []*remoteexecution.OutputDirectory{ + outputDirectoryProto(digestReference{}, rootReference), + }, + }.Build()) actionDigest := strings.Repeat("e", 64) t.Run("complete", func(t *testing.T) { @@ -216,7 +244,7 @@ func TestActionResultReadRejectsInvalidPayload(t *testing.T) { func TestActionResultReadHandlesExistenceCheckErrors(t *testing.T) { outputReference := referenceFor([]byte("output")) - actionResult := bytesField(2, outputFileProto(outputReference, nil)) + actionResult := actionResultProto(t, outputReference) actionDigest := strings.Repeat("f", 64) for _, test := range []struct { @@ -252,7 +280,7 @@ func TestActionResultReadHandlesExistenceCheckErrors(t *testing.T) { func TestActionResultUploadPublishesOnlyCompleteCASClosure(t *testing.T) { output := []byte("persisted output") outputReference := referenceFor(output) - actionResult := bytesField(2, outputFileProto(outputReference, nil)) + actionResult := actionResultProto(t, outputReference) actionDigest := strings.Repeat("d", 64) t.Run("complete", func(t *testing.T) { @@ -295,7 +323,9 @@ func TestActionResultUploadPublishesOnlyCompleteCASClosure(t *testing.T) { func TestActionResultUploadAllowsImplicitEmptyCASDigest(t *testing.T) { emptyReference := referenceFor(nil) - actionResult := bytesField(8, digestProto(emptyReference)) + actionResult := marshalProto(t, remoteexecution.ActionResult_builder{ + StderrDigest: digestProto(emptyReference), + }.Build()) actionDigest := strings.Repeat("2", 64) backend := newMemoryBackend() server := testServer(t, backend, nil) @@ -340,56 +370,55 @@ func referenceFor(data []byte) digestReference { return digestReference{hash: digest(data), size: int64(len(data))} } -func digestProto(reference digestReference) []byte { - return concatProto( - bytesField(1, []byte(reference.hash)), - varintField(2, uint64(reference.size)), - ) +func digestProto(reference digestReference) *remoteexecution.Digest { + return remoteexecution.Digest_builder{ + Hash: reference.hash, + SizeBytes: reference.size, + }.Build() } -func outputFileProto(reference digestReference, inline []byte) []byte { - message := bytesField(2, digestProto(reference)) - if inline != nil { - message = append(message, bytesField(5, inline)...) - } - return message +func outputFileProto(reference digestReference, inline []byte) *remoteexecution.OutputFile { + return remoteexecution.OutputFile_builder{ + Digest: digestProto(reference), + Contents: inline, + }.Build() } -func outputDirectoryProto(tree, root digestReference) []byte { - var message []byte +func outputDirectoryProto(tree, root digestReference) *remoteexecution.OutputDirectory { + message := remoteexecution.OutputDirectory_builder{} if tree.hash != "" { - message = append(message, bytesField(3, digestProto(tree))...) + message.TreeDigest = digestProto(tree) } if root.hash != "" { - message = append(message, bytesField(5, digestProto(root))...) + message.RootDirectoryDigest = digestProto(root) } - return message -} - -func fileNodeProto(reference digestReference) []byte { - return bytesField(2, digestProto(reference)) + return message.Build() } -func directoryNodeProto(reference digestReference) []byte { - return bytesField(2, digestProto(reference)) +func fileNodeProto(reference digestReference) *remoteexecution.FileNode { + return remoteexecution.FileNode_builder{Digest: digestProto(reference)}.Build() } -func bytesField(number protowire.Number, value []byte) []byte { - message := protowire.AppendTag(nil, number, protowire.BytesType) - return protowire.AppendBytes(message, value) +func directoryNodeProto(reference digestReference) *remoteexecution.DirectoryNode { + return remoteexecution.DirectoryNode_builder{Digest: digestProto(reference)}.Build() } -func varintField(number protowire.Number, value uint64) []byte { - message := protowire.AppendTag(nil, number, protowire.VarintType) - return protowire.AppendVarint(message, value) +// actionResultProto builds the minimal action result that references a single CAS +// blob, which is the fixture most cache-level tests need. +func actionResultProto(t *testing.T, output digestReference) []byte { + t.Helper() + return marshalProto(t, remoteexecution.ActionResult_builder{ + OutputFiles: []*remoteexecution.OutputFile{outputFileProto(output, nil)}, + }.Build()) } -func concatProto(fields ...[]byte) []byte { - var message []byte - for _, field := range fields { - message = append(message, field...) +func marshalProto(t *testing.T, message proto.Message) []byte { + t.Helper() + encoded, err := proto.Marshal(message) + if err != nil { + t.Fatal(err) } - return message + return encoded } func assertReferences(t *testing.T, got []digestReference, want ...digestReference) { diff --git a/internal/server/pack_store_test.go b/internal/server/pack_store_test.go index 4754542..75e1886 100644 --- a/internal/server/pack_store_test.go +++ b/internal/server/pack_store_test.go @@ -83,7 +83,7 @@ func TestPackedStoreRoundTripCommitsPackBeforeManifest(t *testing.T) { seed := testPackedServer(t, backend) output := []byte("packed output") outputReference := referenceFor(output) - actionResult := bytesField(2, outputFileProto(outputReference, nil)) + actionResult := actionResultProto(t, outputReference) actionDigest := digest([]byte("packed action")) if response := putCacheObject(seed, "/cas/"+outputReference.hash, output); response.Code != http.StatusNoContent { t.Fatalf("CAS PUT = %d", response.Code) @@ -432,7 +432,7 @@ func seedPackedClosure(t *testing.T, backend *memoryBackend, output []byte, acti } actionWriter := testPackedServer(t, backend) - if response := putCacheObject(actionWriter, "/ac/"+actionDigest, bytesField(2, outputFileProto(reference, nil))); response.Code != http.StatusNoContent { + if response := putCacheObject(actionWriter, "/ac/"+actionDigest, actionResultProto(t, reference)); response.Code != http.StatusNoContent { t.Fatalf("AC PUT = %d", response.Code) } closePackedServer(t, actionWriter) diff --git a/internal/server/reapi_digest.go b/internal/server/reapi_digest.go new file mode 100644 index 0000000..7f1f09f --- /dev/null +++ b/internal/server/reapi_digest.go @@ -0,0 +1,28 @@ +package server + +import ( + "fmt" + + remoteexecution "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2" +) + +const emptySHA256Digest = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + +// digestReferenceFrom validates a decoded REAPI digest and converts it to the +// internal representation. name identifies the enclosing field in error messages. +func digestReferenceFrom(digest *remoteexecution.Digest, name string) (digestReference, error) { + if digest == nil { + return digestReference{}, fmt.Errorf("%s is missing", name) + } + if !digestPattern.MatchString(digest.GetHash()) { + return digestReference{}, fmt.Errorf("%s.hash is not a lowercase SHA-256 digest", name) + } + if digest.GetSizeBytes() < 0 { + return digestReference{}, fmt.Errorf("%s.size_bytes is negative", name) + } + return digestReference{hash: digest.GetHash(), size: digest.GetSizeBytes()}, nil +} + +func isImplicitEmptyDigest(reference digestReference) bool { + return reference.hash == emptySHA256Digest && reference.size == 0 +} diff --git a/internal/server/reapi_directory.go b/internal/server/reapi_directory.go index f6a53c0..ed567cd 100644 --- a/internal/server/reapi_directory.go +++ b/internal/server/reapi_directory.go @@ -5,122 +5,86 @@ import ( "encoding/hex" "errors" "fmt" + "slices" + + "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + remoteexecution "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2" +) + +var ( + treeRootField = treeFieldNumber("root") + treeChildrenField = treeFieldNumber("children") ) +func treeFieldNumber(name protoreflect.Name) protowire.Number { + field := (&remoteexecution.Tree{}).ProtoReflect().Descriptor().Fields().ByName(name) + if field == nil { + panic("build.bazel.remote.execution.v2.Tree has no field " + string(name)) + } + return protowire.Number(field.Number()) +} + type parsedDirectory struct { files []digestReference directories []digestReference } func parseDirectory(data []byte) (parsedDirectory, error) { + message := &remoteexecution.Directory{} + if err := proto.Unmarshal(data, message); err != nil { + return parsedDirectory{}, fmt.Errorf("directory: %w", err) + } var directory parsedDirectory - err := visitWireFields(data, func(field wireField) error { - switch field.number { - case 1: - message, err := field.message("directory.files") - if err != nil { - return err - } - reference, err := parseNodeDigest(message, "file_node") - if err != nil { - return err - } - directory.files = append(directory.files, reference) - case 2: - message, err := field.message("directory.directories") - if err != nil { - return err - } - reference, err := parseNodeDigest(message, "directory_node") - if err != nil { - return err - } - directory.directories = append(directory.directories, reference) - } - return nil - }) - return directory, err -} - -func parseNodeDigest(data []byte, nodeName string) (digestReference, error) { - var digest *digestReference - err := visitWireFields(data, func(field wireField) error { - if field.number != 2 { - return nil - } - message, err := field.message(nodeName + ".digest") + for _, file := range message.GetFiles() { + reference, err := digestReferenceFrom(file.GetDigest(), "file_node.digest") if err != nil { - return err + return parsedDirectory{}, err } - reference, err := parseDigest(message) + directory.files = append(directory.files, reference) + } + for _, child := range message.GetDirectories() { + reference, err := digestReferenceFrom(child.GetDigest(), "directory_node.digest") if err != nil { - return fmt.Errorf("%s.digest: %w", nodeName, err) + return parsedDirectory{}, err } - if digest != nil { - return fmt.Errorf("%s.digest is repeated", nodeName) - } - digest = &reference - return nil - }) - if err != nil { - return digestReference{}, err - } - if digest == nil { - return digestReference{}, fmt.Errorf("%s has no digest", nodeName) + directory.directories = append(directory.directories, reference) } - return *digest, nil + return directory, nil } func parseTree(data []byte) ([]digestReference, error) { - var directories []parsedDirectory - childDigests := make(map[string]int64) - rootSeen := false - - err := visitWireFields(data, func(field wireField) error { - if field.number != 1 && field.number != 2 { - return nil - } - message, err := field.message("tree.directory") - if err != nil { - return err - } - if field.number == 1 { - if rootSeen { - return errors.New("tree.root is repeated") - } - rootSeen = true - } else { - sum := sha256.Sum256(message) - hash := hex.EncodeToString(sum[:]) - if existingSize, exists := childDigests[hash]; exists && existingSize != int64(len(message)) { - return fmt.Errorf("tree child %s has inconsistent sizes", hash) - } - childDigests[hash] = int64(len(message)) - } - directory, err := parseDirectory(message) - if err != nil { - return fmt.Errorf("tree.directory: %w", err) - } - directories = append(directories, directory) - return nil - }) + roots, children, err := splitTree(data) if err != nil { return nil, err } - if !rootSeen { + if len(roots) == 0 { return nil, errors.New("tree has no root directory") } + if len(roots) > 1 { + return nil, errors.New("tree.root is repeated") + } + childDigests := make(map[string]int64, len(children)) + for _, child := range children { + sum := sha256.Sum256(child) + childDigests[hex.EncodeToString(sum[:])] = int64(len(child)) + } files := newDigestCollection() - for _, directory := range directories { + for _, encoded := range slices.Concat(roots, children) { + directory, err := parseDirectory(encoded) + if err != nil { + return nil, fmt.Errorf("tree.directory: %w", err) + } for _, file := range directory.files { if err := files.add(file); err != nil { return nil, err } } for _, child := range directory.directories { - size, exists := childDigests[child.hash] - if !exists || size != child.size { + if size, exists := childDigests[child.hash]; !exists || size != child.size { return nil, fmt.Errorf( "tree references missing child directory %s/%d", child.hash, @@ -131,3 +95,37 @@ func parseTree(data []byte) ([]digestReference, error) { } return files.values, nil } + +// splitTree returns the encoded root and child Directory messages of a Tree. A +// Directory digest covers the exact bytes its producer emitted, so the embedded +// messages have to be hashed as received; re-encoding the decoded messages is not +// guaranteed to reproduce those bytes. +func splitTree(data []byte) (roots [][]byte, children [][]byte, err error) { + for len(data) > 0 { + number, wireType, consumed := protowire.ConsumeTag(data) + if consumed < 0 { + return nil, nil, protowire.ParseError(consumed) + } + data = data[consumed:] + + if wireType == protowire.BytesType && (number == treeRootField || number == treeChildrenField) { + value, n := protowire.ConsumeBytes(data) + if n < 0 { + return nil, nil, protowire.ParseError(n) + } + if number == treeRootField { + roots = append(roots, value) + } else { + children = append(children, value) + } + consumed = n + } else { + consumed = protowire.ConsumeFieldValue(number, wireType, data) + if consumed < 0 { + return nil, nil, protowire.ParseError(consumed) + } + } + data = data[consumed:] + } + return roots, children, nil +} diff --git a/internal/server/reapi_wire.go b/internal/server/reapi_wire.go deleted file mode 100644 index 76b758c..0000000 --- a/internal/server/reapi_wire.go +++ /dev/null @@ -1,112 +0,0 @@ -package server - -import ( - "errors" - "fmt" - "math" - - "google.golang.org/protobuf/encoding/protowire" -) - -const emptySHA256Digest = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - -func parseDigest(data []byte) (digestReference, error) { - var hash string - var size int64 - var hashSeen bool - var sizeSeen bool - err := visitWireFields(data, func(field wireField) error { - switch field.number { - case 1: - value, err := field.message("digest.hash") - if err != nil { - return err - } - if hashSeen { - return errors.New("digest.hash is repeated") - } - hashSeen = true - hash = string(value) - case 2: - if field.wireType != protowire.VarintType { - return errors.New("digest.size_bytes has the wrong wire type") - } - if sizeSeen { - return errors.New("digest.size_bytes is repeated") - } - if field.varintValue > math.MaxInt64 { - return errors.New("digest.size_bytes is negative or overflows int64") - } - sizeSeen = true - size = int64(field.varintValue) - } - return nil - }) - if err != nil { - return digestReference{}, err - } - if !hashSeen || !digestPattern.MatchString(hash) { - return digestReference{}, errors.New("digest.hash is not a lowercase SHA-256 digest") - } - return digestReference{hash: hash, size: size}, nil -} - -func isImplicitEmptyDigest(reference digestReference) bool { - return reference.hash == emptySHA256Digest && reference.size == 0 -} - -type wireField struct { - number protowire.Number - wireType protowire.Type - bytesValue []byte - varintValue uint64 -} - -func (f wireField) message(name string) ([]byte, error) { - if f.wireType != protowire.BytesType { - return nil, fmt.Errorf("%s has the wrong wire type", name) - } - return f.bytesValue, nil -} - -func visitWireFields(data []byte, visit func(wireField) error) error { - for len(data) > 0 { - number, wireType, consumed := protowire.ConsumeTag(data) - if consumed < 0 { - return protowire.ParseError(consumed) - } - if number < 1 { - return errors.New("protobuf field number must be positive") - } - data = data[consumed:] - - field := wireField{number: number, wireType: wireType} - switch wireType { - case protowire.BytesType: - value, n := protowire.ConsumeBytes(data) - if n < 0 { - return protowire.ParseError(n) - } - field.bytesValue = value - consumed = n - case protowire.VarintType: - value, n := protowire.ConsumeVarint(data) - if n < 0 { - return protowire.ParseError(n) - } - field.varintValue = value - consumed = n - default: - consumed = protowire.ConsumeFieldValue(number, wireType, data) - if consumed < 0 { - return protowire.ParseError(consumed) - } - } - - if err := visit(field); err != nil { - return err - } - data = data[consumed:] - } - return nil -} diff --git a/proto/README.md b/proto/README.md new file mode 100644 index 0000000..85b932b --- /dev/null +++ b/proto/README.md @@ -0,0 +1,10 @@ +# Vendored protocol buffer definitions + +The files under `build/` are copied verbatim from +[bazelbuild/remote-apis](https://github.com/bazelbuild/remote-apis) at revision +`9e084d0e43e717128ee72b5be584a7ba33e8006b` (tag `v2.12.0`). Do not edit them by +hand; re-run `scripts/generate-proto.sh --update` to refresh both the vendored +sources and the generated Go code. + +Generated Go code lives in `internal/proto/gen` and is committed so that the +normal `go build` / `go test` flow needs neither `buf` nor `protoc`. diff --git a/proto/buf.lock b/proto/buf.lock new file mode 100644 index 0000000..8447589 --- /dev/null +++ b/proto/buf.lock @@ -0,0 +1,6 @@ +# Generated by buf. DO NOT EDIT. +version: v2 +deps: + - name: buf.build/googleapis/googleapis + commit: c17df5b2beca46928cc87d5656bd5343 + digest: b5:648a01e0170d4512dea7d564016165decd1ed6e34bef79fe54753e51ad7e27545709ad9157d7551270147d551155c595a2fb0bf5bb33b1c83040ddbce915c604 diff --git a/proto/buf.yaml b/proto/buf.yaml new file mode 100644 index 0000000..747115a --- /dev/null +++ b/proto/buf.yaml @@ -0,0 +1,5 @@ +version: v2 +modules: + - path: . +deps: + - buf.build/googleapis/googleapis diff --git a/proto/build/bazel/remote/execution/v2/remote_execution.proto b/proto/build/bazel/remote/execution/v2/remote_execution.proto new file mode 100644 index 0000000..e9cab05 --- /dev/null +++ b/proto/build/bazel/remote/execution/v2/remote_execution.proto @@ -0,0 +1,2511 @@ +// Copyright 2018 The Bazel Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package build.bazel.remote.execution.v2; + +import "build/bazel/semver/semver.proto"; +import "google/api/annotations.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Build.Bazel.Remote.Execution.V2"; +option go_package = "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2;remoteexecution"; +option java_multiple_files = true; +option java_outer_classname = "RemoteExecutionProto"; +option java_package = "build.bazel.remote.execution.v2"; +option objc_class_prefix = "REX"; + + +// The Remote Execution API is used to execute an +// [Action][build.bazel.remote.execution.v2.Action] on the remote +// workers. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +service Execution { + // Execute an action remotely. + // + // In order to execute an action, the client must first upload all of the + // inputs, the + // [Command][build.bazel.remote.execution.v2.Command] to run, and the + // [Action][build.bazel.remote.execution.v2.Action] into the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + // It then calls `Execute` with an `action_digest` referring to them. The + // server will run the action and eventually return the result. + // + // The input `Action`'s fields MUST meet the various canonicalization + // requirements specified in the documentation for their types so that it has + // the same digest as other logically equivalent `Action`s. The server MAY + // enforce the requirements and return errors if a non-canonical input is + // received. It MAY also proceed without verifying some or all of the + // requirements, such as for performance reasons. If the server does not + // verify the requirement, then it will treat the `Action` as distinct from + // another logically equivalent action if they hash differently. + // + // Returns a stream of + // [google.longrunning.Operation][google.longrunning.Operation] messages + // describing the resulting execution, with eventual `response` + // [ExecuteResponse][build.bazel.remote.execution.v2.ExecuteResponse]. The + // `metadata` on the operation is of type + // [ExecuteOperationMetadata][build.bazel.remote.execution.v2.ExecuteOperationMetadata]. + // + // If the client remains connected after the first response is returned after + // the server, then updates are streamed as if the client had called + // [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution] + // until the execution completes or the request reaches an error. The + // operation can also be queried using [Operations + // API][google.longrunning.Operations.GetOperation]. + // + // The server NEED NOT implement other methods or functionality of the + // Operations API. + // + // Errors discovered during creation of the `Operation` will be reported + // as gRPC Status errors, while errors that occurred while running the + // action will be reported in the `status` field of the `ExecuteResponse`. The + // server MUST NOT set the `error` field of the `Operation` proto. + // The possible errors include: + // + // * `INVALID_ARGUMENT`: One or more arguments are invalid. + // * `FAILED_PRECONDITION`: One or more errors occurred in setting up the + // action requested, such as a missing input or command or no worker being + // available. The client may be able to fix the errors and retry. + // * `RESOURCE_EXHAUSTED`: There is insufficient quota of some resource to run + // the action. + // * `UNAVAILABLE`: Due to a transient condition, such as all workers being + // occupied (and the server does not support a queue), the action could not + // be started. The client should retry. + // * `INTERNAL`: An internal error occurred in the execution engine or the + // worker. + // * `DEADLINE_EXCEEDED`: The execution timed out. + // * `CANCELLED`: The operation was cancelled by the client. This status is + // only possible if the server implements the Operations API CancelOperation + // method, and it was called for the current execution. + // + // In the case of a missing input or command, the server SHOULD additionally + // send a [PreconditionFailure][google.rpc.PreconditionFailure] error detail + // where, for each requested blob not present in the CAS, there is a + // `Violation` with a `type` of `MISSING` and a `subject` of + // `"blobs/{digest_function/}{hash}/{size}"` indicating the digest of the + // missing blob. The `subject` is formatted the same way as the + // `resource_name` provided to + // [ByteStream.Read][google.bytestream.ByteStream.Read], with the leading + // instance name omitted. `digest_function` MUST thus be omitted if its value + // is one of MD5, MURMUR3, SHA1, SHA256, SHA384, SHA512, or VSO. + // + // The server does not need to guarantee that a call to this method leads to + // at most one execution of the action. The server MAY execute the action + // multiple times, potentially in parallel. These redundant executions MAY + // continue to run, even if the operation is completed. + rpc Execute(ExecuteRequest) returns (stream google.longrunning.Operation) { + option (google.api.http) = { post: "/v2/{instance_name=**}/actions:execute" body: "*" }; + } + + // Wait for an execution operation to complete. When the client initially + // makes the request, the server immediately responds with the current status + // of the execution. The server will leave the request stream open until the + // operation completes, and then respond with the completed operation. The + // server MAY choose to stream additional updates as execution progresses, + // such as to provide an update as to the state of the execution. + // + // In addition to the cases described for Execute, the WaitExecution method + // may fail as follows: + // + // * `NOT_FOUND`: The operation no longer exists due to any of a transient + // condition, an unknown operation name, or if the server implements the + // Operations API DeleteOperation method and it was called for the current + // execution. The client should call `Execute` to retry. + rpc WaitExecution(WaitExecutionRequest) returns (stream google.longrunning.Operation) { + option (google.api.http) = { post: "/v2/{name=operations/**}:waitExecution" body: "*" }; + } +} + +// The action cache API is used to query whether a given action has already been +// performed and, if so, retrieve its result. Unlike the +// [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage], +// which addresses blobs by their own content, the action cache addresses the +// [ActionResult][build.bazel.remote.execution.v2.ActionResult] by a +// digest of the encoded [Action][build.bazel.remote.execution.v2.Action] +// which produced them. +// +// The lifetime of entries in the action cache is implementation-specific, but +// the server SHOULD assume that more recently used entries are more likely to +// be used again. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +service ActionCache { + // Retrieve a cached execution result. + // + // Implementations SHOULD ensure that any blobs referenced from the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] + // are available at the time of returning the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] and will be + // for some period of time afterwards. The lifetimes of the referenced blobs SHOULD be increased + // if necessary and applicable. + // + // Errors: + // + // * `NOT_FOUND`: The requested `ActionResult` is not in the cache. + rpc GetActionResult(GetActionResultRequest) returns (ActionResult) { + option (google.api.http) = { get: "/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}" }; + } + + // Upload a new execution result. + // + // In order to allow the server to perform access control based on the type of + // action, and to assist with client debugging, the client MUST first upload + // the [Action][build.bazel.remote.execution.v2.Action] that produced the + // result, along with its + // [Command][build.bazel.remote.execution.v2.Command], into the + // `ContentAddressableStorage`. + // + // Server implementations MAY modify the + // `UpdateActionResultRequest.action_result` and return an equivalent value. + // + // Errors: + // + // * `INVALID_ARGUMENT`: One or more arguments are invalid. + // * `FAILED_PRECONDITION`: One or more errors occurred in updating the + // action result, such as a missing command or action. + // * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the + // entry to the cache. + rpc UpdateActionResult(UpdateActionResultRequest) returns (ActionResult) { + option (google.api.http) = { put: "/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}" body: "action_result" }; + } +} + +// The CAS (content-addressable storage) is used to store the inputs to and +// outputs from the execution service. Each piece of content is addressed by the +// digest of its binary data. +// +// Most of the binary data stored in the CAS is opaque to the execution engine, +// and is only used as a communication medium. In order to build an +// [Action][build.bazel.remote.execution.v2.Action], +// however, the client will need to also upload the +// [Command][build.bazel.remote.execution.v2.Command] and input root +// [Directory][build.bazel.remote.execution.v2.Directory] for the Action. +// The Command and Directory messages must be marshalled to wire format and then +// uploaded under the hash as with any other piece of content. In practice, the +// input root directory is likely to refer to other Directories in its +// hierarchy, which must also each be uploaded on their own. +// +// For small file uploads the client should group them together and call +// [BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +// +// For large uploads, the client must use the +// [Write method][google.bytestream.ByteStream.Write] of the ByteStream API. +// +// For uncompressed data, the `WriteRequest.resource_name` is of the following form: +// `{instance_name}/uploads/{uuid}/blobs/{digest_function/}{hash}/{size}{/optional_metadata}` +// +// Where: +// * `instance_name` is an identifier used to distinguish between the various +// instances on the server. Syntax and semantics of this field are defined +// by the server; Clients must not make any assumptions about it (e.g., +// whether it spans multiple path segments or not). If it is the empty path, +// the leading slash is omitted, so that the `resource_name` becomes +// `uploads/{uuid}/blobs/{digest_function/}{hash}/{size}{/optional_metadata}`. +// To simplify parsing, a path segment cannot equal any of the following +// keywords: `blobs`, `uploads`, `actions`, `actionResults`, `operations`, +// `capabilities` or `compressed-blobs`. +// * `uuid` is a version 4 UUID generated by the client, used to avoid +// collisions between concurrent uploads of the same data. Clients MAY +// reuse the same `uuid` for uploading different blobs. +// * `digest_function` is a lowercase string form of a `DigestFunction.Value` +// enum, indicating which digest function was used to compute `hash`. If the +// digest function used is one of MD5, MURMUR3, SHA1, SHA256, SHA384, SHA512, +// or VSO, this component MUST be omitted. In that case the server SHOULD +// infer the digest function using the length of the `hash` and the digest +// functions announced in the server's capabilities. +// * `hash` and `size` refer to the [Digest][build.bazel.remote.execution.v2.Digest] +// of the data being uploaded. +// * `optional_metadata` is implementation specific data, which clients MAY omit. +// Servers MAY ignore this metadata. +// +// Data can alternatively be uploaded in compressed form, with the following +// `WriteRequest.resource_name` form: +// `{instance_name}/uploads/{uuid}/compressed-blobs/{compressor}/{digest_function/}{uncompressed_hash}/{uncompressed_size}{/optional_metadata}` +// +// Where: +// * `instance_name`, `uuid`, `digest_function` and `optional_metadata` are +// defined as above. +// * `compressor` is a lowercase string form of a `Compressor.Value` enum +// other than `identity`, which is supported by the server and advertised in +// [CacheCapabilities.supported_compressors][build.bazel.remote.execution.v2.CacheCapabilities.supported_compressors]. +// * `uncompressed_hash` and `uncompressed_size` refer to the +// [Digest][build.bazel.remote.execution.v2.Digest] of the data being +// uploaded, once uncompressed. Servers MUST verify that these match +// the uploaded data once uncompressed, and MUST return an +// `INVALID_ARGUMENT` error in the case of mismatch. +// +// Note that when writing compressed blobs, the `WriteRequest.write_offset` in +// the initial request in a stream refers to the offset in the uncompressed form +// of the blob. In subsequent requests, `WriteRequest.write_offset` MUST be the +// sum of the first request's 'WriteRequest.write_offset' and the total size of +// all the compressed data bundles in the previous requests. +// Note that this mixes an uncompressed offset with a compressed byte length, +// which is nonsensical, but it is done to fit the semantics of the existing +// ByteStream protocol. +// +// Uploads of the same data MAY occur concurrently in any form, compressed or +// uncompressed. +// +// Clients SHOULD NOT use gRPC-level compression for ByteStream API `Write` +// calls of compressed blobs, since this would compress already-compressed data. +// +// When attempting an upload, if another client has already completed the upload +// (which may occur in the middle of a single upload if another client uploads +// the same blob concurrently), the request will terminate immediately without +// error, and with a response whose `committed_size` is the value `-1` if this +// is a compressed upload, or with the full size of the uploaded file if this is +// an uncompressed upload (regardless of how much data was transmitted by the +// client). If the client completes the upload but the +// [Digest][build.bazel.remote.execution.v2.Digest] does not match, an +// `INVALID_ARGUMENT` error will be returned. In either case, the client should +// not attempt to retry the upload. +// +// Small downloads can be grouped and requested in a batch via +// [BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. +// +// For large downloads, the client must use the +// [Read method][google.bytestream.ByteStream.Read] of the ByteStream API. +// +// For uncompressed data, the `ReadRequest.resource_name` is of the following form: +// `{instance_name}/blobs/{digest_function/}{hash}/{size}` +// Where `instance_name`, `digest_function`, `hash` and `size` are defined as +// for uploads. +// +// Data can alternatively be downloaded in compressed form, with the following +// `ReadRequest.resource_name` form: +// `{instance_name}/compressed-blobs/{compressor}/{digest_function/}{uncompressed_hash}/{uncompressed_size}` +// +// Where: +// * `instance_name`, `compressor` and `digest_function` are defined as for +// uploads. +// * `uncompressed_hash` and `uncompressed_size` refer to the +// [Digest][build.bazel.remote.execution.v2.Digest] of the data being +// downloaded, once uncompressed. Clients MUST verify that these match +// the downloaded data once uncompressed, and take appropriate steps in +// the case of failure such as retrying a limited number of times or +// surfacing an error to the user. +// +// When downloading compressed blobs: +// * `ReadRequest.read_offset` refers to the offset in the uncompressed form +// of the blob. +// * Servers MUST return `INVALID_ARGUMENT` if `ReadRequest.read_limit` is +// non-zero. +// * Servers MAY use any compression level they choose, including different +// levels for different blobs (e.g. choosing a level designed for maximum +// speed for data known to be incompressible). +// * Clients SHOULD NOT use gRPC-level compression, since this would compress +// already-compressed data. +// +// Servers MUST be able to provide data for all recently advertised blobs in +// each of the compression formats that the server supports, as well as in +// uncompressed form. +// +// Additionally, ByteStream requests MAY come with an additional plain text header +// that indicates the `resource_name` of the blob being sent. The header, if +// present, MUST follow the following convention: +// * name: `build.bazel.remote.execution.v2.resource-name`. +// * contents: the plain text resource_name of the request message. +// If set, the contents of the header MUST match the `resource_name` of the request +// message. Servers MAY use this header to assist in routing requests to the +// appropriate backend. +// +// The lifetime of entries in the CAS is implementation specific, but it SHOULD +// be long enough to allow for newly-added and recently looked-up entries to be +// used in subsequent calls (e.g. to +// [Execute][build.bazel.remote.execution.v2.Execution.Execute]). +// +// Servers MUST behave as though empty blobs are always available, even if they +// have not been uploaded. Clients MAY optimize away the uploading or +// downloading of empty blobs. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +service ContentAddressableStorage { + // Determine if blobs are present in the CAS. + // + // Clients can use this API before uploading blobs to determine which ones are + // already present in the CAS and do not need to be uploaded again. + // + // Servers SHOULD increase the lifetimes of the referenced blobs if necessary and + // applicable. + // + // There are no method-specific errors. + rpc FindMissingBlobs(FindMissingBlobsRequest) returns (FindMissingBlobsResponse) { + option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:findMissing" body: "*" }; + } + + // Upload many blobs at once. + // + // The server may enforce a limit of the combined total size of blobs + // to be uploaded using this API. This limit may be obtained using the + // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. + // Requests exceeding the limit should either be split into smaller + // chunks or uploaded using the + // [ByteStream API][google.bytestream.ByteStream], as appropriate. + // + // This request is equivalent to calling a Bytestream `Write` request + // on each individual blob, in parallel. The requests may succeed or fail + // independently. + // + // Errors: + // + // * `INVALID_ARGUMENT`: The client attempted to upload more than the + // server supported limit. + // + // Individual requests may return the following errors, additionally: + // + // * `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob. + // * `INVALID_ARGUMENT`: The + // [Digest][build.bazel.remote.execution.v2.Digest] does not match the + // provided data. + rpc BatchUpdateBlobs(BatchUpdateBlobsRequest) returns (BatchUpdateBlobsResponse) { + option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:batchUpdate" body: "*" }; + } + + // Download many blobs at once. + // + // The server may enforce a limit of the combined total size of blobs + // to be downloaded using this API. This limit may be obtained using the + // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. + // Requests exceeding the limit should either be split into smaller + // chunks or downloaded using the + // [ByteStream API][google.bytestream.ByteStream], as appropriate. + // + // This request is equivalent to calling a Bytestream `Read` request + // on each individual blob, in parallel. The requests may succeed or fail + // independently. + // + // Errors: + // + // * `INVALID_ARGUMENT`: The client attempted to read more than the + // server supported limit. + // + // Every error on individual read will be returned in the corresponding digest + // status. + rpc BatchReadBlobs(BatchReadBlobsRequest) returns (BatchReadBlobsResponse) { + option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:batchRead" body: "*" }; + } + + // Fetch the entire directory tree rooted at a node. + // + // This request must be targeted at a + // [Directory][build.bazel.remote.execution.v2.Directory] stored in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] + // (CAS). The server will enumerate the `Directory` tree recursively and + // return every node descended from the root. + // + // The GetTreeRequest.page_token parameter can be used to skip ahead in + // the stream (e.g. when retrying a partially completed and aborted request), + // by setting it to a value taken from GetTreeResponse.next_page_token of the + // last successfully processed GetTreeResponse). + // + // The exact traversal order is unspecified and, unless retrieving subsequent + // pages from an earlier request, is not guaranteed to be stable across + // multiple invocations of `GetTree`. + // + // If part of the tree is missing from the CAS, the server will return the + // portion present and omit the rest. + // + // Errors: + // + // * `NOT_FOUND`: The requested tree root is not present in the CAS. + rpc GetTree(GetTreeRequest) returns (stream GetTreeResponse) { + option (google.api.http) = { get: "/v2/{instance_name=**}/blobs/{root_digest.hash}/{root_digest.size_bytes}:getTree" }; + } + + // SplitBlob retrieves information about how a blob is split into chunks. + // + // This call returns information about how a blob is split into chunks, and + // returns a list of the chunk digests. Using the returned list of chunk digests, + // a client can check which chunks are locally available and only fetch the + // missing ones. The desired blob can be assembled by concatenating the fetched + // chunks in the order of the digests in the list. The chunks SHOULD all be + // available in the CAS. + // + // This API can be used to reduce the required data to download a large blob + // from CAS if some chunks from similar blobs are locally available. For this + // procedure to work properly, blobs SHOULD be split in a content-defined way, + // rather than with fixed-sized chunking. + // + // If a split request is answered successfully, a client can expect the + // following guarantees from the server: + // 1. The blob chunks are stored in CAS. + // 2. Concatenating the blob chunks in the order of the digest list returned + // by the server results in the original blob. + // + // Servers which implement this functionality MUST declare that they support + // it by setting the + // [CacheCapabilities.split_blob_support][build.bazel.remote.execution.v2.CacheCapabilities.split_blob_support] + // field accordingly. + // + // Clients MUST check that the server supports this capability, before using + // it. + // + // Clients SHOULD verify that the digest of the blob assembled by the fetched + // chunks is equal to the requested blob digest. + // + // The lifetimes of the generated chunk blobs MAY be independent of the + // lifetime of the original blob. In particular: + // * A blob and any chunk derived from it MAY be evicted from the CAS at + // different times. + // * A call to [SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // extends the lifetime of the original blob, and sets the lifetimes of + // the resulting chunks (or extends the lifetimes of already-existing + // chunks). + // * Touching a chunk extends its lifetime, but the server MAY choose not + // to extend the lifetime of the original blob. + // * Touching the original blob extends its lifetime, but the server MAY + // choose not to extend the lifetimes of chunks derived from it. + // + // When blob splitting and splicing is used at the same time, the clients and + // the server SHOULD agree out-of-band upon a chunking algorithm used by both + // parties to benefit from each other's chunk data and avoid unnecessary data + // duplication. + // + // Errors: + // + // * `NOT_FOUND`: The requested blob is not present in the CAS, OR there is no + // split information available for the blob, OR at least one chunk needed to + // reconstruct the blob is missing from the CAS. + // * `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob + // chunks. + rpc SplitBlob(SplitBlobRequest) returns (SplitBlobResponse) { + option (google.api.http) = { get: "/v2/{instance_name=**}/blobs/{blob_digest.hash}/{blob_digest.size_bytes}:splitBlob" }; + } + + // SpliceBlob tells the CAS how chunks can compose a blob. + // + // This is the complementary operation to the + // [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // function to handle the chunked upload of large blobs to save upload + // traffic. + // + // When uploading a large blob using chunked upload, clients MUST first upload + // all chunks to the CAS, then call this RPC to tell the server how those chunks + // compose the original blob. The chunks referenced in the SpliceBlob call SHOULD be + // available in the CAS before calling this RPC. + // + // If a client needs to upload a large blob and is able to split a blob into + // chunks in such a way that reusable chunks are obtained, e.g., by means of + // content-defined chunking, it can first determine which parts of the blob + // are already available in the remote CAS and upload the missing chunks, and + // then use this API to store information on how the chunks compose the + // original blob. + // + // Servers which implement this functionality MUST declare that they support + // it by setting the + // [CacheCapabilities.splice_blob_support][build.bazel.remote.execution.v2.CacheCapabilities.splice_blob_support] + // field accordingly. + // + // Clients MUST check that the server supports this capability, before using + // it. + // + // In order to ensure data consistency of the CAS, the server MUST only add + // blobs to the CAS after verifying their digests. In particular, servers MUST NOT + // trust digests provided by the client. The server MAY accept a request as no-op + // if the client-specified blob is already in CAS or if information on how to + // construct the blob from chunks is available. If the client-specified blob is + // not already in the CAS, the server MUST verify that the digest of the newly + // created blob assembled from chunks matches the digest specified by the + // client, and reject the request if they differ. Servers MAY choose to allow + // overwriting existing chunk mappings or to store multiple chunk mappings for + // the same blob. + // + // When blob splitting and splicing is used at the same time, the clients and + // the server SHOULD agree out-of-band upon a chunking algorithm used by both + // parties to benefit from each other's chunk data and avoid unnecessary data + // duplication. + // + // Errors: + // + // * `NOT_FOUND`: At least one of the blob chunks is not present in the CAS. + // * `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the + // spliced blob. + // * `INVALID_ARGUMENT`: The digest of the spliced blob is different from the + // provided expected digest. + // * `ALREADY_EXISTS`: The blob already exists in CAS and the server did not + // extend the lifetime of the chunks specified in the request, e.g. because + // it prefers a different chunking and extended those instead. Clients can + // call [SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // to check what chunk mapping the server is using. + rpc SpliceBlob(SpliceBlobRequest) returns (SpliceBlobResponse) { + option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:spliceBlob" body: "*" }; + } +} + +// The Capabilities service may be used by remote execution clients to query +// various server properties, in order to self-configure or return meaningful +// error messages. +// +// The query may include a particular `instance_name`, in which case the values +// returned will pertain to that instance. +service Capabilities { + // GetCapabilities returns the server capabilities configuration of the + // remote endpoint. + // Only the capabilities of the services supported by the endpoint will + // be returned: + // * Execution + CAS + Action Cache endpoints should return both + // CacheCapabilities and ExecutionCapabilities. + // * Execution only endpoints should return ExecutionCapabilities. + // * CAS + Action Cache only endpoints should return CacheCapabilities. + // + // There are no method-specific errors. + rpc GetCapabilities(GetCapabilitiesRequest) returns (ServerCapabilities) { + option (google.api.http) = { + get: "/v2/{instance_name=**}/capabilities" + }; + } +} + +// An `Action` captures all the information about an execution which is required +// to reproduce it. +// +// `Action`s are the core component of the [Execution] service. A single +// `Action` represents a repeatable action that can be performed by the +// execution service. `Action`s can be succinctly identified by the digest of +// their wire format encoding and, once an `Action` has been executed, will be +// cached in the action cache. Future requests can then use the cached result +// rather than needing to run afresh. +// +// When a server completes execution of an +// [Action][build.bazel.remote.execution.v2.Action], it MAY choose to +// cache the [result][build.bazel.remote.execution.v2.ActionResult] in +// the [ActionCache][build.bazel.remote.execution.v2.ActionCache] unless +// `do_not_cache` is `true`. Clients SHOULD expect the server to do so. By +// default, future calls to +// [Execute][build.bazel.remote.execution.v2.Execution.Execute] the same +// `Action` will also serve their results from the cache. Clients must take care +// to understand the caching behaviour. Ideally, all `Action`s will be +// reproducible so that serving a result from cache is always desirable and +// correct. +message Action { + // The digest of the [Command][build.bazel.remote.execution.v2.Command] + // to run, which MUST be present in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + Digest command_digest = 1; + + // The digest of the root + // [Directory][build.bazel.remote.execution.v2.Directory] for the input + // files. The files in the directory tree are available in the correct + // location on the build machine before the command is executed. The root + // directory, as well as every subdirectory and content blob referred to, MUST + // be in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + Digest input_root_digest = 2; + + reserved 3 to 5; // Used for fields moved to [Command][build.bazel.remote.execution.v2.Command]. + + // A timeout after which the execution should be killed. If the timeout is + // absent, then the client is specifying that the execution should continue + // as long as the server will let it. The server SHOULD impose a timeout if + // the client does not specify one, however, if the client does specify a + // timeout that is longer than the server's maximum timeout, the server MUST + // reject the request. + // + // The timeout is only intended to cover the "execution" of the specified + // action and not time in queue nor any overheads before or after execution + // such as marshalling inputs/outputs. The server SHOULD avoid including time + // spent the client doesn't have control over, and MAY extend or reduce the + // timeout to account for delays or speedups that occur during execution + // itself (e.g., lazily loading data from the Content Addressable Storage, + // live migration of virtual machines, emulation overhead). + // + // The timeout is a part of the + // [Action][build.bazel.remote.execution.v2.Action] message, and + // therefore two `Actions` with different timeouts are different, even if they + // are otherwise identical. This is because, if they were not, running an + // `Action` with a lower timeout than is required might result in a cache hit + // from an execution run with a longer timeout, hiding the fact that the + // timeout is too short. By encoding it directly in the `Action`, a lower + // timeout will result in a cache miss and the execution timeout will fail + // immediately, rather than whenever the cache entry gets evicted. + google.protobuf.Duration timeout = 6; + + // If true, then the `Action`'s result cannot be cached, and in-flight + // requests for the same `Action` may not be merged. + bool do_not_cache = 7; + + reserved 8; // Used for field moved to [Command][build.bazel.remote.execution.v2.Command]. + + // An optional additional salt value used to place this `Action` into a + // separate cache namespace from other instances having the same field + // contents. This salt typically comes from operational configuration + // specific to sources such as repo and service configuration, + // and allows disowning an entire set of ActionResults that might have been + // poisoned by buggy software or tool failures. + bytes salt = 9; + + // The optional platform requirements for the execution environment. The + // server MAY choose to execute the action on any worker satisfying the + // requirements, so the client SHOULD ensure that running the action on any + // such worker will have the same result. A detailed lexicon for this can be + // found in the accompanying platform.md. + // New in version 2.2: clients SHOULD set these platform properties as well + // as those in the [Command][build.bazel.remote.execution.v2.Command]. Servers + // SHOULD prefer those set here. + Platform platform = 10; +} + +// A `Command` is the actual command executed by a worker running an +// [Action][build.bazel.remote.execution.v2.Action] and specifications of its +// environment. +// +// Except as otherwise required, the environment (such as which system +// libraries or binaries are available, and what filesystems are mounted where) +// is defined by and specific to the implementation of the remote execution API. +message Command { + // An `EnvironmentVariable` is one variable to set in the running program's + // environment. + message EnvironmentVariable { + // The variable name. + string name = 1; + + // The variable value. + string value = 2; + } + + // The arguments to the command. + // + // The first argument specifies the command to run, which may be either an + // absolute path, a path relative to the working directory, or an unqualified + // path (without path separators) which will be resolved using the operating + // system's equivalent of the PATH environment variable. Path separators + // native to the operating system running on the worker SHOULD be used. If the + // `environment_variables` list contains an entry for the PATH environment + // variable, it SHOULD be respected. If not, the resolution process is + // implementation-defined. + // + // Changed in v2.3. v2.2 and older require that no PATH lookups are performed, + // and that relative paths are resolved relative to the input root. This + // behavior can, however, not be relied upon, as most implementations already + // followed the rules described above. + repeated string arguments = 1; + + // The environment variables to set when running the program. The worker may + // provide its own default environment variables; these defaults can be + // overridden using this field. Additional variables can also be specified. + // + // In order to ensure that equivalent + // [Command][build.bazel.remote.execution.v2.Command]s always hash to the same + // value, the environment variables MUST be lexicographically sorted by name. + // Sorting of strings is done by code point, equivalently, by the UTF-8 bytes. + repeated EnvironmentVariable environment_variables = 2; + + // A list of the output files that the client expects to retrieve from the + // action. Only the listed files, as well as directories listed in + // `output_directories`, will be returned to the client as output. + // Other files or directories that may be created during command execution + // are discarded. + // + // The paths are relative to the working directory of the action execution. + // The paths are specified using a single forward slash (`/`) as a path + // separator, even if the execution platform natively uses a different + // separator. The path MUST NOT include a trailing slash, nor a leading slash, + // being a relative path. + // + // In order to ensure consistent hashing of the same Action, the output paths + // MUST be sorted lexicographically by code point (or, equivalently, by UTF-8 + // bytes). + // + // An output file cannot be duplicated, be a parent of another output file, or + // have the same path as any of the listed output directories. + // + // Directories leading up to the output files are created by the worker prior + // to execution, even if they are not explicitly part of the input root. + // + // DEPRECATED since v2.1: Use `output_paths` instead. + repeated string output_files = 3 [ deprecated = true ]; + + // A list of the output directories that the client expects to retrieve from + // the action. Only the listed directories will be returned (an entire + // directory structure will be returned as a + // [Tree][build.bazel.remote.execution.v2.Tree] message digest, see + // [OutputDirectory][build.bazel.remote.execution.v2.OutputDirectory]), as + // well as files listed in `output_files`. Other files or directories that + // may be created during command execution are discarded. + // + // The paths are relative to the working directory of the action execution. + // The paths are specified using a single forward slash (`/`) as a path + // separator, even if the execution platform natively uses a different + // separator. The path MUST NOT include a trailing slash, nor a leading slash, + // being a relative path. The special value of empty string is allowed, + // although not recommended, and can be used to capture the entire working + // directory tree, including inputs. + // + // In order to ensure consistent hashing of the same Action, the output paths + // MUST be sorted lexicographically by code point (or, equivalently, by UTF-8 + // bytes). + // + // An output directory cannot be duplicated or have the same path as any of + // the listed output files. An output directory is allowed to be a parent of + // another output directory. + // + // Directories leading up to the output directories (but not the output + // directories themselves) are created by the worker prior to execution, even + // if they are not explicitly part of the input root. + // + // DEPRECATED since 2.1: Use `output_paths` instead. + repeated string output_directories = 4 [ deprecated = true ]; + + // A list of the output paths that the client expects to retrieve from the + // action. Only the listed paths will be returned to the client as output. + // The type of the output (file or directory) is not specified, and will be + // determined by the server after action execution. If the resulting path is + // a file, it will be returned in an + // [OutputFile][build.bazel.remote.execution.v2.OutputFile] typed field. + // If the path is a directory, the entire directory structure will be returned + // as a [Tree][build.bazel.remote.execution.v2.Tree] message digest, see + // [OutputDirectory][build.bazel.remote.execution.v2.OutputDirectory] + // Other files or directories that may be created during command execution + // are discarded. + // + // The paths are relative to the working directory of the action execution. + // The paths are specified using a single forward slash (`/`) as a path + // separator, even if the execution platform natively uses a different + // separator. The path MUST NOT include a trailing slash, nor a leading slash, + // being a relative path. + // + // In order to ensure consistent hashing of the same Action, the output paths + // MUST be deduplicated and sorted lexicographically by code point (or, + // equivalently, by UTF-8 bytes). + // + // Directories leading up to the output paths are created by the worker prior + // to execution, even if they are not explicitly part of the input root. + // + // New in v2.1: this field supersedes the DEPRECATED `output_files` and + // `output_directories` fields. If `output_paths` is used, `output_files` and + // `output_directories` will be ignored! + repeated string output_paths = 7; + + // The platform requirements for the execution environment. The server MAY + // choose to execute the action on any worker satisfying the requirements, so + // the client SHOULD ensure that running the action on any such worker will + // have the same result. A detailed lexicon for this can be found in the + // accompanying platform.md. + // DEPRECATED as of v2.2: platform properties are now specified directly in + // the action. See documentation note in the + // [Action][build.bazel.remote.execution.v2.Action] for migration. + Platform platform = 5 [ deprecated = true ]; + + // The working directory, relative to the input root, for the command to run + // in. It must be a directory which exists in the input tree. If it is left + // empty, then the action is run in the input root. + string working_directory = 6; + + // A list of keys for node properties the client expects to retrieve for + // output files and directories. Keys are either names of string-based + // [NodeProperty][build.bazel.remote.execution.v2.NodeProperty] or + // names of fields in [NodeProperties][build.bazel.remote.execution.v2.NodeProperties]. + // In order to ensure that equivalent `Action`s always hash to the same + // value, the node properties MUST be lexicographically sorted by name. + // Sorting of strings is done by code point, equivalently, by the UTF-8 bytes. + // + // The interpretation of string-based properties is server-dependent. If a + // property is not recognized by the server, the server will return an + // `INVALID_ARGUMENT`. + repeated string output_node_properties = 8; + + enum OutputDirectoryFormat { + // The client is only interested in receiving output directories in + // the form of a single Tree object, using the `tree_digest` field. + TREE_ONLY = 0; + + // The client is only interested in receiving output directories in + // the form of a hierarchy of separately stored Directory objects, + // using the `root_directory_digest` field. + DIRECTORY_ONLY = 1; + + // The client is interested in receiving output directories both in + // the form of a single Tree object and a hierarchy of separately + // stored Directory objects, using both the `tree_digest` and + // `root_directory_digest` fields. + TREE_AND_DIRECTORY = 2; + } + + // The format that the worker should use to store the contents of + // output directories. + // + // In case this field is set to a value that is not supported by the + // worker, the worker SHOULD interpret this field as TREE_ONLY. The + // worker MAY store output directories in formats that are a superset + // of what was requested (e.g., interpreting DIRECTORY_ONLY as + // TREE_AND_DIRECTORY). + OutputDirectoryFormat output_directory_format = 9; +} + +// A `Platform` is a set of requirements, such as hardware, operating system, or +// compiler toolchain, for an +// [Action][build.bazel.remote.execution.v2.Action]'s execution +// environment. A `Platform` is represented as a series of key-value pairs +// representing the properties that are required of the platform. +message Platform { + // A single property for the environment. The server is responsible for + // specifying the property `name`s that it accepts. If an unknown `name` is + // provided in the requirements for an + // [Action][build.bazel.remote.execution.v2.Action], the server SHOULD + // reject the execution request. If permitted by the server, the same `name` + // may occur multiple times. + // + // The server is also responsible for specifying the interpretation of + // property `value`s. For instance, a property describing how much RAM must be + // available may be interpreted as allowing a worker with 16GB to fulfill a + // request for 8GB, while a property describing the OS environment on which + // the action must be performed may require an exact match with the worker's + // OS. + // + // The server MAY use the `value` of one or more properties to determine how + // it sets up the execution environment, such as by making specific system + // files available to the worker. + // + // Both names and values are typically case-sensitive. Note that the platform + // is implicitly part of the action digest, so even tiny changes in the names + // or values (like changing case) may result in different action cache + // entries. + message Property { + // The property name. + string name = 1; + + // The property value. + string value = 2; + } + + // The properties that make up this platform. In order to ensure that + // equivalent `Platform`s always hash to the same value, the properties MUST + // be lexicographically sorted by name, and then by value. Sorting of strings + // is done by code point, equivalently, by the UTF-8 bytes. + repeated Property properties = 1; +} + +// A `Directory` represents a directory node in a file tree, containing zero or +// more children [FileNodes][build.bazel.remote.execution.v2.FileNode], +// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode] and +// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. +// Each `Node` contains its name in the directory, either the digest of its +// content (either a file blob or a `Directory` proto) or a symlink target, as +// well as possibly some metadata about the file or directory. +// +// In order to ensure that two equivalent directory trees hash to the same +// value, the following restrictions MUST be obeyed when constructing +// a `Directory`: +// +// * Every child in the directory must have a path of exactly one segment. +// Multiple levels of directory hierarchy may not be collapsed. +// * Each child in the directory must have a unique path segment (file name). +// Note that while the API itself is case-sensitive, the environment where +// the Action is executed may or may not be case-sensitive. That is, it is +// legal to call the API with a Directory that has both "Foo" and "foo" as +// children, but the Action may be rejected by the remote system upon +// execution. +// * The files, directories and symlinks in the directory must each be sorted +// in lexicographical order by path. The path strings must be sorted by code +// point, equivalently, by UTF-8 bytes. +// * The [NodeProperties][build.bazel.remote.execution.v2.NodeProperty] of files, +// directories, and symlinks must be sorted in lexicographical order by +// property name. +// +// A `Directory` that obeys the restrictions is said to be in canonical form. +// +// As an example, the following could be used for a file named `bar` and a +// directory named `foo` with an executable file named `baz` (hashes shortened +// for readability): +// +// ```json +// // (Directory proto) +// { +// files: [ +// { +// name: "bar", +// digest: { +// hash: "4a73bc9d03...", +// size: 65534 +// }, +// node_properties: [ +// { +// "name": "MTime", +// "value": "2017-01-15T01:30:15.01Z" +// } +// ] +// } +// ], +// directories: [ +// { +// name: "foo", +// digest: { +// hash: "4cf2eda940...", +// size: 43 +// } +// } +// ] +// } +// +// // (Directory proto with hash "4cf2eda940..." and size 43) +// { +// files: [ +// { +// name: "baz", +// digest: { +// hash: "b2c941073e...", +// size: 1294, +// }, +// is_executable: true +// } +// ] +// } +// ``` +message Directory { + // The files in the directory. + repeated FileNode files = 1; + + // The subdirectories in the directory. + repeated DirectoryNode directories = 2; + + // The symlinks in the directory. + repeated SymlinkNode symlinks = 3; + + // The node properties of the Directory. + reserved 4; + NodeProperties node_properties = 5; +} + +// A single property for [FileNodes][build.bazel.remote.execution.v2.FileNode], +// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode], and +// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. The server is +// responsible for specifying the property `name`s that it accepts. If +// permitted by the server, the same `name` may occur multiple times. +message NodeProperty { + // The property name. + string name = 1; + + // The property value. + string value = 2; +} + +// Node properties for [FileNodes][build.bazel.remote.execution.v2.FileNode], +// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode], and +// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. The server is +// responsible for specifying the properties that it accepts. +// +message NodeProperties { + // A list of string-based + // [NodeProperties][build.bazel.remote.execution.v2.NodeProperty]. + repeated NodeProperty properties = 1; + + // The file's last modification timestamp. + google.protobuf.Timestamp mtime = 2; + + // The UNIX file mode, e.g., 0755. + google.protobuf.UInt32Value unix_mode = 3; +} + +// A `FileNode` represents a single file and associated metadata. +message FileNode { + // The name of the file. + string name = 1; + + // The digest of the file's content. + Digest digest = 2; + + reserved 3; // Reserved to ensure wire-compatibility with `OutputFile`. + + // True if file is executable, false otherwise. + bool is_executable = 4; + + // The node properties of the FileNode. + reserved 5; + NodeProperties node_properties = 6; +} + +// A `DirectoryNode` represents a child of a +// [Directory][build.bazel.remote.execution.v2.Directory] which is itself +// a `Directory` and its associated metadata. +message DirectoryNode { + // The name of the directory. + string name = 1; + + // The digest of the + // [Directory][build.bazel.remote.execution.v2.Directory] object + // represented. See [Digest][build.bazel.remote.execution.v2.Digest] + // for information about how to take the digest of a proto message. + Digest digest = 2; +} + +// A `SymlinkNode` represents a symbolic link. +message SymlinkNode { + // The name of the symlink. + string name = 1; + + // The target path of the symlink. The path separator is a forward slash `/`. + // The target path can be relative to the parent directory of the symlink or + // it can be an absolute path starting with `/`. Support for absolute paths + // can be checked using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] + // API. `..` components are allowed anywhere in the target path as logical + // canonicalization may lead to different behavior in the presence of + // directory symlinks (e.g. `foo/../bar` may not be the same as `bar`). + // To reduce potential cache misses, canonicalization is still recommended + // where this is possible without impacting correctness. + string target = 2; + + // The node properties of the SymlinkNode. + reserved 3; + NodeProperties node_properties = 4; +} + +// A content digest. A digest for a given blob consists of the size of the blob +// and its hash. The hash algorithm to use is defined by the server. +// +// The size is considered to be an integral part of the digest and cannot be +// separated. That is, even if the `hash` field is correctly specified but +// `size_bytes` is not, the server MUST reject the request. +// +// The reason for including the size in the digest is as follows: in a great +// many cases, the server needs to know the size of the blob it is about to work +// with prior to starting an operation with it, such as flattening Merkle tree +// structures or streaming it to a worker. Technically, the server could +// implement a separate metadata store, but this results in a significantly more +// complicated implementation as opposed to having the client specify the size +// up-front (or storing the size along with the digest in every message where +// digests are embedded). This does mean that the API leaks some implementation +// details of (what we consider to be) a reasonable server implementation, but +// we consider this to be a worthwhile tradeoff. +// +// When a `Digest` is used to refer to a proto message, it always refers to the +// message in binary encoded form. To ensure consistent hashing, clients and +// servers MUST ensure that they serialize messages according to the following +// rules, even if there are alternate valid encodings for the same message: +// +// * Fields are serialized in tag order. +// * There are no unknown fields. +// * There are no duplicate fields. +// * Fields are serialized according to the default semantics for their type. +// +// Most protocol buffer implementations will always follow these rules when +// serializing, but care should be taken to avoid shortcuts. For instance, +// concatenating two messages to merge them may produce duplicate fields. +message Digest { + // The hash, represented as a lowercase hexadecimal string, padded with + // leading zeroes up to the hash function length. + string hash = 1; + + // The size of the blob, in bytes. + int64 size_bytes = 2; +} + +// ExecutedActionMetadata contains details about a completed execution. +message ExecutedActionMetadata { + // The name of the worker which ran the execution. + string worker = 1; + + // When was the action added to the queue. + google.protobuf.Timestamp queued_timestamp = 2; + + // When the worker received the action. + google.protobuf.Timestamp worker_start_timestamp = 3; + + // When the worker completed the action, including all stages. + google.protobuf.Timestamp worker_completed_timestamp = 4; + + // When the worker started fetching action inputs. + google.protobuf.Timestamp input_fetch_start_timestamp = 5; + + // When the worker finished fetching action inputs. + google.protobuf.Timestamp input_fetch_completed_timestamp = 6; + + // When the worker started executing the action command. + google.protobuf.Timestamp execution_start_timestamp = 7; + + // When the worker completed executing the action command. + google.protobuf.Timestamp execution_completed_timestamp = 8; + + // New in v2.3: the amount of time the worker spent executing the action + // command, potentially computed using a worker-specific virtual clock. + // + // The virtual execution duration is only intended to cover the "execution" of + // the specified action and not time in queue nor any overheads before or + // after execution such as marshalling inputs/outputs. The server SHOULD avoid + // including time spent the client doesn't have control over, and MAY extend + // or reduce the execution duration to account for delays or speedups that + // occur during execution itself (e.g., lazily loading data from the Content + // Addressable Storage, live migration of virtual machines, emulation + // overhead). + // + // The method of timekeeping used to compute the virtual execution duration + // MUST be consistent with what is used to enforce the + // [Action][build.bazel.remote.execution.v2.Action]'s `timeout`. There is no + // relationship between the virtual execution duration and the values of + // `execution_start_timestamp` and `execution_completed_timestamp`. + google.protobuf.Duration virtual_execution_duration = 12; + + // When the worker started uploading action outputs. + google.protobuf.Timestamp output_upload_start_timestamp = 9; + + // When the worker finished uploading action outputs. + google.protobuf.Timestamp output_upload_completed_timestamp = 10; + + // Details that are specific to the kind of worker used. For example, + // on POSIX-like systems this could contain a message with + // getrusage(2) statistics. + repeated google.protobuf.Any auxiliary_metadata = 11; +} + +// An ActionResult represents the result of an +// [Action][build.bazel.remote.execution.v2.Action] being run. +// +// It is advised that at least one field (for example +// `ActionResult.execution_metadata.Worker`) have a non-default value, to +// ensure that the serialized value is non-empty, which can then be used +// as a basic data sanity check. +message ActionResult { + reserved 1; // Reserved for use as the resource name. + + // The output files of the action. For each output file requested in the + // `output_files` or `output_paths` field of the Action, if the corresponding + // file existed after the action completed, a single entry will be present + // either in this field, or the `output_file_symlinks` field if the file was + // a symbolic link to another file (`output_symlinks` field after v2.1). + // + // If an output listed in `output_files` was found, but was a directory rather + // than a regular file, the server will return a FAILED_PRECONDITION. + // If the action does not produce the requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + repeated OutputFile output_files = 2; + + // The output files of the action that are symbolic links to other files. Those + // may be links to other output files, or input files, or even absolute paths + // outside of the working directory, if the server supports + // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. + // For each output file requested in the `output_files` or `output_paths` + // field of the Action, if the corresponding file existed after + // the action completed, a single entry will be present either in this field, + // or in the `output_files` field, if the file was not a symbolic link. + // + // If an output symbolic link of the same name as listed in `output_files` of + // the Command was found, but its target type was not a regular file, the + // server will return a FAILED_PRECONDITION. + // If the action does not produce the requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + // + // DEPRECATED as of v2.1. Servers that wish to be compatible with v2.0 API + // should still populate this field in addition to `output_symlinks`. + repeated OutputSymlink output_file_symlinks = 10 [ deprecated = true ]; + + // New in v2.1: this field will only be populated if the command + // `output_paths` field was used, and not the pre v2.1 `output_files` or + // `output_directories` fields. + // The output paths of the action that are symbolic links to other paths. Those + // may be links to other outputs, or inputs, or even absolute paths + // outside of the working directory, if the server supports + // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. + // A single entry for each output requested in `output_paths` + // field of the Action, if the corresponding path existed after + // the action completed and was a symbolic link. + // + // If the action does not produce a requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + repeated OutputSymlink output_symlinks = 12; + + // The output directories of the action. For each output directory requested + // in the `output_directories` or `output_paths` field of the Action, if the + // corresponding directory existed after the action completed, a single entry + // will be present in the output list, which will contain the digest of a + // [Tree][build.bazel.remote.execution.v2.Tree] message containing the + // directory tree, and the path equal exactly to the corresponding Action + // output_directories member. + // + // As an example, suppose the Action had an output directory `a/b/dir` and the + // execution produced the following contents in `a/b/dir`: a file named `bar` + // and a directory named `foo` with an executable file named `baz`. Then, + // output_directory will contain (hashes shortened for readability): + // + // ```json + // // OutputDirectory proto: + // { + // path: "a/b/dir" + // tree_digest: { + // hash: "4a73bc9d03...", + // size: 55 + // } + // } + // // Tree proto with hash "4a73bc9d03..." and size 55: + // { + // root: { + // files: [ + // { + // name: "bar", + // digest: { + // hash: "4a73bc9d03...", + // size: 65534 + // } + // } + // ], + // directories: [ + // { + // name: "foo", + // digest: { + // hash: "4cf2eda940...", + // size: 43 + // } + // } + // ] + // } + // children : { + // // (Directory proto with hash "4cf2eda940..." and size 43) + // files: [ + // { + // name: "baz", + // digest: { + // hash: "b2c941073e...", + // size: 1294, + // }, + // is_executable: true + // } + // ] + // } + // } + // ``` + // If an output of the same name as listed in `output_files` of + // the Command was found in `output_directories`, but was not a directory, the + // server will return a FAILED_PRECONDITION. + repeated OutputDirectory output_directories = 3; + + // The output directories of the action that are symbolic links to other + // directories. Those may be links to other output directories, or input + // directories, or even absolute paths outside of the working directory, + // if the server supports + // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. + // For each output directory requested in the `output_directories` field of + // the Action, if the directory existed after the action completed, a + // single entry will be present either in this field, or in the + // `output_directories` field, if the directory was not a symbolic link. + // + // If an output of the same name was found, but was a symbolic link to a file + // instead of a directory, the server will return a FAILED_PRECONDITION. + // If the action does not produce the requested output, then that output + // will be omitted from the list. The server is free to arrange the output + // list as desired; clients MUST NOT assume that the output list is sorted. + // + // DEPRECATED as of v2.1. Servers that wish to be compatible with v2.0 API + // should still populate this field in addition to `output_symlinks`. + repeated OutputSymlink output_directory_symlinks = 11 [ deprecated = true ]; + + // The exit code of the command. + int32 exit_code = 4; + + // The standard output buffer of the action. The server SHOULD NOT inline + // stdout unless requested by the client in the + // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] + // message. The server MAY omit inlining, even if requested, and MUST do so if inlining + // would cause the response to exceed message size limits. + // Clients SHOULD NOT populate this field when uploading to the cache. + bytes stdout_raw = 5; + + // The digest for a blob containing the standard output of the action, which + // can be retrieved from the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + Digest stdout_digest = 6; + + // The standard error buffer of the action. The server SHOULD NOT inline + // stderr unless requested by the client in the + // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] + // message. The server MAY omit inlining, even if requested, and MUST do so if inlining + // would cause the response to exceed message size limits. + // Clients SHOULD NOT populate this field when uploading to the cache. + bytes stderr_raw = 7; + + // The digest for a blob containing the standard error of the action, which + // can be retrieved from the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + Digest stderr_digest = 8; + + // The details of the execution that originally produced this result. + ExecutedActionMetadata execution_metadata = 9; +} + +// An `OutputFile` is similar to a +// [FileNode][build.bazel.remote.execution.v2.FileNode], but it is used as an +// output in an `ActionResult`. It allows a full file path rather than +// only a name. +message OutputFile { + // The full path of the file relative to the working directory, including the + // filename. The path separator is a forward slash `/`. Since this is a + // relative path, it MUST NOT begin with a leading forward slash. + string path = 1; + + // The digest of the file's content. + Digest digest = 2; + + reserved 3; // Used for a removed field in an earlier version of the API. + + // True if file is executable, false otherwise. + bool is_executable = 4; + + // The contents of the file if inlining was requested. The server SHOULD NOT inline + // file contents unless requested by the client in the + // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] + // message. The server MAY omit inlining, even if requested, and MUST do so if inlining + // would cause the response to exceed message size limits. + // Clients SHOULD NOT populate this field when uploading to the cache. + bytes contents = 5; + + // The supported node properties of the OutputFile, if requested by the Action. + reserved 6; + NodeProperties node_properties = 7; +} + +// A `Tree` contains all the +// [Directory][build.bazel.remote.execution.v2.Directory] protos in a +// single directory Merkle tree, compressed into one message. +message Tree { + // The root directory in the tree. + Directory root = 1; + + // All the child directories: the directories referred to by the root and, + // recursively, all its children. In order to reconstruct the directory tree, + // the client must take the digests of each of the child directories and then + // build up a tree starting from the `root`. + // Servers SHOULD ensure that these are ordered consistently such that two + // actions producing equivalent output directories on the same server + // implementation also produce Tree messages with matching digests. + repeated Directory children = 2; +} + +// An `OutputDirectory` is the output in an `ActionResult` corresponding to a +// directory's full contents rather than a single file. +message OutputDirectory { + // The full path of the directory relative to the working directory. The path + // separator is a forward slash `/`. Since this is a relative path, it MUST + // NOT begin with a leading forward slash. The empty string value is allowed, + // and it denotes the entire working directory. + string path = 1; + + reserved 2; // Used for a removed field in an earlier version of the API. + + // The digest of the encoded + // [Tree][build.bazel.remote.execution.v2.Tree] proto containing the + // directory's contents. + Digest tree_digest = 3; + + // If set, consumers MAY make the following assumptions about the + // directories contained in the Tree, so that it may be + // instantiated on a local file system by scanning through it + // sequentially: + // + // - All directories with the same binary representation are stored + // exactly once. + // - All directories, apart from the root directory, are referenced by + // at least one parent directory. + // - Directories are stored in topological order, with parents being + // stored before the child. The root directory is thus the first to + // be stored. + // + // Additionally, the Tree MUST be encoded as a stream of records, + // where each record has the following format: + // + // - A tag byte, having one of the following two values: + // - (1 << 3) | 2 == 0x0a: First record (the root directory). + // - (2 << 3) | 2 == 0x12: Any subsequent records (child directories). + // - The size of the directory, encoded as a base 128 varint. + // - The contents of the directory, encoded as a binary serialized + // Protobuf message. + // + // This encoding is a subset of the Protobuf wire format of the Tree + // message. As it is only permitted to store data associated with + // field numbers 1 and 2, the tag MUST be encoded as a single byte. + // More details on the Protobuf wire format can be found here: + // https://developers.google.com/protocol-buffers/docs/encoding + // + // It is recommended that implementations using this feature construct + // Tree objects manually using the specification given above, as + // opposed to using a Protobuf library to marshal a full Tree message. + // As individual Directory messages already need to be marshaled to + // compute their digests, constructing the Tree object manually avoids + // redundant marshaling. + bool is_topologically_sorted = 4; + + // The digest of the encoded + // [Directory][build.bazel.remote.execution.v2.Directory] proto + // containing the contents of the directory's root. + // + // If both `tree_digest` and `root_directory_digest` are set, this + // field MUST match the digest of the root directory contained in the + // Tree message. + Digest root_directory_digest = 5; +} + +// An `OutputSymlink` is similar to a +// [Symlink][build.bazel.remote.execution.v2.SymlinkNode], but it is used as an +// output in an `ActionResult`. +// +// `OutputSymlink` is binary-compatible with `SymlinkNode`. +message OutputSymlink { + // The full path of the symlink relative to the working directory, including the + // filename. The path separator is a forward slash `/`. Since this is a + // relative path, it MUST NOT begin with a leading forward slash. + string path = 1; + + // The target path of the symlink. The path separator is a forward slash `/`. + // The target path can be relative to the parent directory of the symlink or + // it can be an absolute path starting with `/`. Support for absolute paths + // can be checked using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] + // API. `..` components are allowed anywhere in the target path. + string target = 2; + + // The supported node properties of the OutputSymlink, if requested by the + // Action. + reserved 3; + NodeProperties node_properties = 4; +} + +// An `ExecutionPolicy` can be used to control the scheduling of the action. +message ExecutionPolicy { + // The priority (relative importance) of this action. Generally, a lower value + // means that the action should be run sooner than actions having a greater + // priority value, but the interpretation of a given value is server- + // dependent. A priority of 0 means the *default* priority. Priorities may be + // positive or negative, and such actions should run later or sooner than + // actions having the default priority, respectively. The particular semantics + // of this field is up to the server. In particular, every server will have + // their own supported range of priorities, and will decide how these map into + // scheduling policy. + int32 priority = 1; +} + +// A `ResultsCachePolicy` is used for fine-grained control over how action +// outputs are stored in the CAS and Action Cache. +message ResultsCachePolicy { + // The priority (relative importance) of this content in the overall cache. + // Generally, a lower value means a longer retention time or other advantage, + // but the interpretation of a given value is server-dependent. A priority of + // 0 means a *default* value, decided by the server. + // + // The particular semantics of this field is up to the server. In particular, + // every server will have their own supported range of priorities, and will + // decide how these map into retention/eviction policy. + int32 priority = 1; +} + +// A request message for +// [Execution.Execute][build.bazel.remote.execution.v2.Execution.Execute]. +message ExecuteRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // If true, the action will be executed even if its result is already + // present in the [ActionCache][build.bazel.remote.execution.v2.ActionCache]. + // The execution is still allowed to be merged with other in-flight executions + // of the same action, however - semantically, the service MUST only guarantee + // that the results of an execution with this field set were not visible + // before the corresponding execution request was sent. + // Note that actions from execution requests setting this field set are still + // eligible to be entered into the action cache upon completion, and services + // SHOULD overwrite any existing entries that may exist. This allows + // skip_cache_lookup requests to be used as a mechanism for replacing action + // cache entries that reference outputs no longer available or that are + // poisoned in any way. + // If false, the result may be served from the action cache. + bool skip_cache_lookup = 3; + + reserved 2, 4, 5; // Used for removed fields in an earlier version of the API. + + // The digest of the [Action][build.bazel.remote.execution.v2.Action] to + // execute. + Digest action_digest = 6; + + // An optional policy for execution of the action. + // The server will have a default policy if this is not provided. + ExecutionPolicy execution_policy = 7; + + // An optional policy for the results of this execution in the remote cache. + // The server will have a default policy if this is not provided. + // This may be applied to both the ActionResult and the associated blobs. + ResultsCachePolicy results_cache_policy = 8; + + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the action digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 9; + + // A hint to the server to request inlining stdout in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + bool inline_stdout = 10; + + // A hint to the server to request inlining stderr in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + bool inline_stderr = 11; + + // A hint to the server to inline the contents of the listed output files. + // Each path needs to exactly match one file path in either `output_paths` or + // `output_files` (DEPRECATED since v2.1) in the + // [Command][build.bazel.remote.execution.v2.Command] message. + repeated string inline_output_files = 12; +} + +// A `LogFile` is a log stored in the CAS. +message LogFile { + // The digest of the log contents. + Digest digest = 1; + + // This is a hint as to the purpose of the log, and is set to true if the log + // is human-readable text that can be usefully displayed to a user, and false + // otherwise. For instance, if a command-line client wishes to print the + // server logs to the terminal for a failed action, this allows it to avoid + // displaying a binary file. + bool human_readable = 2; +} + +// The response message for +// [Execution.Execute][build.bazel.remote.execution.v2.Execution.Execute], +// which will be contained in the [response +// field][google.longrunning.Operation.response] of the +// [Operation][google.longrunning.Operation]. +message ExecuteResponse { + // The result of the action. + ActionResult result = 1; + + // True if the result was served from cache, false if it was executed. + bool cached_result = 2; + + // If the status has a code other than `OK`, it indicates that the action did + // not finish execution. For example, if the operation times out during + // execution, the status will have a `DEADLINE_EXCEEDED` code. Servers MUST + // use this field for errors in execution, rather than the error field on the + // `Operation` object. + // + // If the status code is other than `OK`, then the result MUST NOT be cached. + // For an error status, the `result` field is optional; the server may + // populate the output-, stdout-, and stderr-related fields if it has any + // information available, such as the stdout and stderr of a timed-out action. + google.rpc.Status status = 3; + + // An optional list of additional log outputs the server wishes to provide. A + // server can use this to return execution-specific logs however it wishes. + // This is intended primarily to make it easier for users to debug issues that + // may be outside of the actual job execution, such as by identifying the + // worker executing the action or by providing logs from the worker's setup + // phase. The keys SHOULD be human readable so that a client can display them + // to a user. + map server_logs = 4; + + // Freeform informational message with details on the execution of the action + // that may be displayed to the user upon failure or when requested explicitly. + string message = 5; +} + +// The current stage of action execution. +// +// Even though these stages are numbered according to the order in which +// they generally occur, there is no requirement that the remote +// execution system reports events along this order. For example, an +// operation MAY transition from the EXECUTING stage back to QUEUED +// in case the hardware on which the operation executes fails. +// +// If and only if the remote execution system reports that an operation +// has reached the COMPLETED stage, it MUST set the [done +// field][google.longrunning.Operation.done] of the +// [Operation][google.longrunning.Operation] and terminate the stream. +message ExecutionStage { + enum Value { + // Invalid value. + UNKNOWN = 0; + + // Checking the result against the cache. + CACHE_CHECK = 1; + + // Currently idle, awaiting a free machine to execute. + QUEUED = 2; + + // Currently being executed by a worker. + EXECUTING = 3; + + // Finished execution. + COMPLETED = 4; + } +} + +// Metadata about an ongoing +// [execution][build.bazel.remote.execution.v2.Execution.Execute], which +// will be contained in the [metadata +// field][google.longrunning.Operation.metadata] of the +// [Operation][google.longrunning.Operation]. +message ExecuteOperationMetadata { + // The current stage of execution. + ExecutionStage.Value stage = 1; + + // The digest of the [Action][build.bazel.remote.execution.v2.Action] + // being executed. + Digest action_digest = 2; + + // If set, the client can use this resource name with + // [ByteStream.Read][google.bytestream.ByteStream.Read] to stream the + // standard output from the endpoint hosting streamed responses. + string stdout_stream_name = 3; + + // If set, the client can use this resource name with + // [ByteStream.Read][google.bytestream.ByteStream.Read] to stream the + // standard error from the endpoint hosting streamed responses. + string stderr_stream_name = 4; + + // The client can read this field to view details about the ongoing + // execution. + ExecutedActionMetadata partial_execution_metadata = 5; + + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of BLAKE3, MD5, MURMUR3, SHA1, + // SHA256, SHA256TREE, SHA384, SHA512, or VSO, the server MAY leave + // this field unset. In that case the client SHOULD infer the digest + // function using the length of the action digest hash and the digest + // functions announced in the server's capabilities. + DigestFunction.Value digest_function = 6; +} + +// A request message for +// [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution]. +message WaitExecutionRequest { + // The name of the [Operation][google.longrunning.Operation] + // returned by [Execute][build.bazel.remote.execution.v2.Execution.Execute]. + string name = 1; +} + +// A request message for +// [ActionCache.GetActionResult][build.bazel.remote.execution.v2.ActionCache.GetActionResult]. +message GetActionResultRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The digest of the [Action][build.bazel.remote.execution.v2.Action] + // whose result is requested. + Digest action_digest = 2; + + // A hint to the server to request inlining stdout in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + bool inline_stdout = 3; + + // A hint to the server to request inlining stderr in the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. + bool inline_stderr = 4; + + // A hint to the server to inline the contents of the listed output files. + // Each path needs to exactly match one file path in either `output_paths` or + // `output_files` (DEPRECATED since v2.1) in the + // [Command][build.bazel.remote.execution.v2.Command] message. + repeated string inline_output_files = 5; + + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the action digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 6; +} + +// A request message for +// [ActionCache.UpdateActionResult][build.bazel.remote.execution.v2.ActionCache.UpdateActionResult]. +message UpdateActionResultRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The digest of the [Action][build.bazel.remote.execution.v2.Action] + // whose result is being uploaded. + Digest action_digest = 2; + + // The [ActionResult][build.bazel.remote.execution.v2.ActionResult] + // to store in the cache. + ActionResult action_result = 3; + + // An optional policy for the results of this execution in the remote cache. + // The server will have a default policy if this is not provided. + // This may be applied to both the ActionResult and the associated blobs. + ResultsCachePolicy results_cache_policy = 4; + + // The digest function that was used to compute the action digest. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the action digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 5; +} + +// A request message for +// [ContentAddressableStorage.FindMissingBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs]. +message FindMissingBlobsRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // A list of the blobs to check. All digests MUST use the same digest + // function. + repeated Digest blob_digests = 2; + + // The digest function of the blobs whose existence is checked. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 3; +} + +// A response message for +// [ContentAddressableStorage.FindMissingBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs]. +message FindMissingBlobsResponse { + // A list of the blobs requested *not* present in the storage. + repeated Digest missing_blob_digests = 2; +} + +// A request message for +// [ContentAddressableStorage.BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +message BatchUpdateBlobsRequest { + // A request corresponding to a single blob that the client wants to upload. + message Request { + // The digest of the blob. This MUST be the digest of `data`. All + // digests MUST use the same digest function. + Digest digest = 1; + + // The raw binary data. + bytes data = 2; + + // The format of `data`. Must be `IDENTITY`/unspecified, or one of the + // compressors advertised by the + // [CacheCapabilities.supported_batch_update_compressors][build.bazel.remote.execution.v2.CacheCapabilities.supported_batch_update_compressors] + // field. + Compressor.Value compressor = 3; + } + + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The individual upload requests. + repeated Request requests = 2; + + // The digest function that was used to compute the digests of the + // blobs being uploaded. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 5; +} + +// A response message for +// [ContentAddressableStorage.BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +message BatchUpdateBlobsResponse { + // A response corresponding to a single blob that the client tried to upload. + message Response { + // The blob digest to which this response corresponds. + Digest digest = 1; + + // The result of attempting to upload that blob. + google.rpc.Status status = 2; + } + + // The responses to the requests. + repeated Response responses = 1; +} + +// A request message for +// [ContentAddressableStorage.BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. +message BatchReadBlobsRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The individual blob digests. All digests MUST use the same digest + // function. + repeated Digest digests = 2; + + // A list of acceptable encodings for the returned inlined data, in no + // particular order. `IDENTITY` is always allowed even if not specified here. + repeated Compressor.Value acceptable_compressors = 3; + + // The digest function of the blobs being requested. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 4; +} + +// A response message for +// [ContentAddressableStorage.BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. +message BatchReadBlobsResponse { + // A response corresponding to a single blob that the client tried to download. + message Response { + // The digest to which this response corresponds. + Digest digest = 1; + + // The raw binary data. + bytes data = 2; + + // The format the data is encoded in. MUST be `IDENTITY`/unspecified, + // or one of the acceptable compressors specified in the `BatchReadBlobsRequest`. + Compressor.Value compressor = 4; + + // The result of attempting to download that blob. + google.rpc.Status status = 3; + } + + // The responses to the requests. + repeated Response responses = 1; +} + +// A request message for +// [ContentAddressableStorage.GetTree][build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree]. +message GetTreeRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The digest of the root, which must be an encoded + // [Directory][build.bazel.remote.execution.v2.Directory] message + // stored in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + Digest root_digest = 2; + + // A maximum page size to request. If present, the server will request no more + // than this many items. Regardless of whether a page size is specified, the + // server may place its own limit on the number of items to be returned and + // require the client to retrieve more items using a subsequent request. + int32 page_size = 3; + + // A page token, which must be a value received in a previous + // [GetTreeResponse][build.bazel.remote.execution.v2.GetTreeResponse]. + // If present, the server will use that token as an offset, returning only + // that page and the ones that succeed it. + string page_token = 4; + + // The digest function that was used to compute the digest of the root + // directory. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the root digest hash and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 5; +} + +// A response message for +// [ContentAddressableStorage.GetTree][build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree]. +message GetTreeResponse { + // The directories descended from the requested root. + repeated Directory directories = 1; + + // If present, signifies that there are more results which the client can + // retrieve by passing this as the page_token in a subsequent + // [request][build.bazel.remote.execution.v2.GetTreeRequest]. + // If empty, signifies that this is the last page of results. + string next_page_token = 2; +} + +// A request message for +// [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob]. +message SplitBlobRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The digest of the blob to be split. + Digest blob_digest = 2; + + // The digest function of the blob to be split. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, + // SHA384, SHA512, or VSO, the client MAY leave this field unset. In + // that case the server SHOULD infer the digest function using the + // length of the blob digest hashes and the digest functions announced + // in the server's capabilities. + DigestFunction.Value digest_function = 3; + + // The chunking function that the client prefers to use. + // + // The server MAY use a different chunking function. + ChunkingFunction.Value chunking_function = 4; +} + +// A response message for +// [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob]. +message SplitBlobResponse { + // The ordered list of digests of the chunks into which the blob was split. + // The original blob is assembled by concatenating the chunk data according to + // the order of the digests given by this list. + // + // The server MUST use the same digest function as the one explicitly or + // implicitly (through hash length) specified in the split request. + repeated Digest chunk_digests = 1; + + // The chunking function used to split the blob. + ChunkingFunction.Value chunking_function = 2; +} + +// A request message for +// [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob]. +message SpliceBlobRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // Expected digest of the spliced blob. The client MUST set this field due + // to the following reasons: + // 1. It allows the server to perform an early existence check of the blob + // or existing chunks that assemble the blob before spending the splicing + // effort, as described in the [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob] + // documentation. + // 2. It allows servers with different storage backends to dispatch the + // request to the correct storage backend based on the size and/or the + // hash of the blob. + // 3. If chunking information already exists for the blob, it allows + // the server to keep the existing chunking information or replace it with + // new chunking information. + Digest blob_digest = 2; + + // The ordered list of digests of the chunks which need to be concatenated to + // assemble the original blob. + repeated Digest chunk_digests = 3; + + // The digest function of all chunks to be concatenated and of the blob to be + // spliced. The server MUST use the same digest function for both cases. + // + // If the digest function used is one of MD5, MURMUR3, SHA1, SHA256, SHA384, + // SHA512, or VSO, the client MAY leave this field unset. In that case the + // server SHOULD infer the digest function using the length of the blob digest + // hashes and the digest functions announced in the server's capabilities. + DigestFunction.Value digest_function = 4; + + // The chunking function that the client used to split the blob. + ChunkingFunction.Value chunking_function = 5; +} + +// A response message for +// [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob]. +message SpliceBlobResponse { + // Computed digest of the spliced blob. + // + // The server MUST use the same digest function as the one explicitly or + // implicitly (through hash length) specified in the splice request. + Digest blob_digest = 1; +} + +// A request message for +// [Capabilities.GetCapabilities][build.bazel.remote.execution.v2.Capabilities.GetCapabilities]. +message GetCapabilitiesRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; +} + +// A response message for +// [Capabilities.GetCapabilities][build.bazel.remote.execution.v2.Capabilities.GetCapabilities]. +message ServerCapabilities { + // Capabilities of the remote cache system. + CacheCapabilities cache_capabilities = 1; + + // Capabilities of the remote execution system. + ExecutionCapabilities execution_capabilities = 2; + + // Earliest RE API version supported, including deprecated versions. + build.bazel.semver.SemVer deprecated_api_version = 3; + + // Earliest non-deprecated RE API version supported. + build.bazel.semver.SemVer low_api_version = 4; + + // Latest RE API version supported. + build.bazel.semver.SemVer high_api_version = 5; +} + +// The digest function used for converting values into keys for CAS and Action +// Cache. +message DigestFunction { + enum Value { + // It is an error for the server to return this value. + UNKNOWN = 0; + + // The SHA-256 digest function. + SHA256 = 1; + + // The SHA-1 digest function. + SHA1 = 2; + + // The MD5 digest function. + MD5 = 3; + + // The Microsoft "VSO-Hash" paged SHA256 digest function. + // See https://github.com/microsoft/BuildXL/blob/master/Documentation/Specs/PagedHash.md . + VSO = 4; + + // The SHA-384 digest function. + SHA384 = 5; + + // The SHA-512 digest function. + SHA512 = 6; + + // Murmur3 128-bit digest function, x64 variant. Note that this is not a + // cryptographic hash function and its collision properties are not strongly guaranteed. + // See https://github.com/aappleby/smhasher/wiki/MurmurHash3 . + MURMUR3 = 7; + + // The SHA-256 digest function, modified to use a Merkle tree for + // large objects. This permits implementations to store large blobs + // as a decomposed sequence of 2^j sized chunks, where j >= 10, + // while being able to validate integrity at the chunk level. + // + // Furthermore, on systems that do not offer dedicated instructions + // for computing SHA-256 hashes (e.g., the Intel SHA and ARMv8 + // cryptographic extensions), SHA256TREE hashes can be computed more + // efficiently than plain SHA-256 hashes by using generic SIMD + // extensions, such as Intel AVX2 or ARM NEON. + // + // SHA256TREE hashes are computed as follows: + // + // - For blobs that are 1024 bytes or smaller, the hash is computed + // using the regular SHA-256 digest function. + // + // - For blobs that are more than 1024 bytes in size, the hash is + // computed as follows: + // + // 1. The blob is partitioned into a left (leading) and right + // (trailing) blob. These blobs have lengths m and n + // respectively, where m = 2^k and 0 < n <= m. + // + // 2. Hashes of the left and right blob, Hash(left) and + // Hash(right) respectively, are computed by recursively + // applying the SHA256TREE algorithm. + // + // 3. A single invocation is made to the SHA-256 block cipher with + // the following parameters: + // + // M = Hash(left) || Hash(right) + // H = { + // 0xcbbb9d5d, 0x629a292a, 0x9159015a, 0x152fecd8, + // 0x67332667, 0x8eb44a87, 0xdb0c2e0d, 0x47b5481d, + // } + // + // The values of H are the leading fractional parts of the + // square roots of the 9th to the 16th prime number (23 to 53). + // This differs from plain SHA-256, where the first eight prime + // numbers (2 to 19) are used, thereby preventing trivial hash + // collisions between small and large objects. + // + // 4. The hash of the full blob can then be obtained by + // concatenating the outputs of the block cipher: + // + // Hash(blob) = a || b || c || d || e || f || g || h + // + // Addition of the original values of H, as normally done + // through the use of the Davies-Meyer structure, is not + // performed. This isn't necessary, as the block cipher is only + // invoked once. + // + // Test vectors of this digest function can be found in the + // accompanying sha256tree_test_vectors.txt file. + SHA256TREE = 8; + + // The BLAKE3 hash function. + // See https://github.com/BLAKE3-team/BLAKE3. + BLAKE3 = 9; + + // Identical to SHA1, except that "blob ${sizeBytes}\0" is prepended to + // the blob's contents before hashing, where ${sizeBytes} corresponds to + // the decimal size of the original blob. This allows hashes of files to + // be converted from and to the ones used by the Git version control + // system. + GITSHA1 = 10; + } +} + +// The chunking function is used to split a blob into chunks. +// +// The server advertises support for a chunking function by setting the +// corresponding params field in +// [CacheCapabilities][build.bazel.remote.execution.v2.CacheCapabilities]. +// For example, if fast_cdc_2020_params is set, the server supports FAST_CDC_2020. +// +// For optimal deduplication, clients SHOULD use an advertised chunking function. +// When clients use UNKNOWN, the server chooses an algorithm for SplitBlob and +// simply verifies chunk concatenation for SpliceBlob. +message ChunkingFunction { + enum Value { + // No specific algorithm. Servers MUST always accept this value. + // For SplitBlob, the server chooses the algorithm. For SpliceBlob, the + // server only verifies that chunks concatenate to form the expected blob. + UNKNOWN = 0; + + // The FastCDC chunking algorithm as described in the 2020 paper by + // Wen Xia, et al. See https://ieeexplore.ieee.org/document/9055082 + // for details. + FAST_CDC_2020 = 1; + + // The RepMaxCDC chunking algorithm as implemented by buildbarn/go-cdc. + // See https://github.com/buildbarn/go-cdc for details. + REP_MAX_CDC = 2; + } +} + +// Describes the server/instance capabilities for updating the action cache. +message ActionCacheUpdateCapabilities { + bool update_enabled = 1; +} + +// Allowed values for priority in +// [ResultsCachePolicy][build.bazel.remote.execution.v2.ResultsCachePolicy] and +// [ExecutionPolicy][build.bazel.remote.execution.v2.ExecutionPolicy] +// Used for querying both cache and execution valid priority ranges. +message PriorityCapabilities { + // Supported range of priorities, including boundaries. + message PriorityRange { + // The minimum numeric value for this priority range, which represents the + // most urgent task or longest retained item. + int32 min_priority = 1; + // The maximum numeric value for this priority range, which represents the + // least urgent task or shortest retained item. + int32 max_priority = 2; + } + repeated PriorityRange priorities = 1; +} + +// Describes how the server treats absolute symlink targets. +message SymlinkAbsolutePathStrategy { + enum Value { + // Invalid value. + UNKNOWN = 0; + + // Server will return an `INVALID_ARGUMENT` on input symlinks with absolute + // targets. + // If an action tries to create an output symlink with an absolute target, a + // `FAILED_PRECONDITION` will be returned. + DISALLOWED = 1; + + // Server will allow symlink targets to escape the input root tree, possibly + // resulting in non-hermetic builds. + ALLOWED = 2; + } +} + +// Compression formats which may be supported. +message Compressor { + enum Value { + // No compression. Servers and clients MUST always support this, and do + // not need to advertise it. + IDENTITY = 0; + + // Zstandard compression. + ZSTD = 1; + + // RFC 1951 Deflate. This format is identical to what is used by ZIP + // files. Headers such as the one generated by gzip are not + // included. + // + // It is advised to use algorithms such as Zstandard instead, as + // those are faster and/or provide a better compression ratio. + DEFLATE = 2; + + // Brotli compression. + BROTLI = 3; + } +} + +// Capabilities of the remote cache system. +message CacheCapabilities { + // All the digest functions supported by the remote cache. + // Remote cache may support multiple digest functions simultaneously. + repeated DigestFunction.Value digest_functions = 1; + + // Capabilities for updating the action cache. + ActionCacheUpdateCapabilities action_cache_update_capabilities = 2; + + // Supported cache priority range for both CAS and ActionCache. + PriorityCapabilities cache_priority_capabilities = 3; + + // Maximum total size of blobs to be uploaded/downloaded using + // batch methods. A value of 0 means no limit is set, although + // in practice there will always be a message size limitation + // of the protocol in use, e.g. GRPC. + int64 max_batch_total_size_bytes = 4; + + // Whether absolute symlink targets are supported. + SymlinkAbsolutePathStrategy.Value symlink_absolute_path_strategy = 5; + + // Compressors supported by the "compressed-blobs" bytestream resources. + // Servers MUST support identity/no-compression, even if it is not listed + // here. + // + // Note that this does not imply which if any compressors are supported by + // the server at the gRPC level. + repeated Compressor.Value supported_compressors = 6; + + // Compressors supported for inlined data in + // [BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs] + // requests. + repeated Compressor.Value supported_batch_update_compressors = 7; + + // The maximum blob size that the server will accept for CAS blob uploads. + // - If it is 0, it means there is no limit set. A client may assume + // arbitrarily large blobs may be uploaded to and downloaded from the cache. + // - If it is larger than 0, implementations SHOULD NOT attempt to upload + // blobs with size larger than the limit. Servers SHOULD reject blob + // uploads over the `max_cas_blob_size_bytes` limit with response code + // `INVALID_ARGUMENT` + // - If the cache implementation returns a given limit, it MAY still serve + // blobs larger than this limit. + int64 max_cas_blob_size_bytes = 8; + + // Whether blob splitting is supported for the particular server/instance. If + // yes, the server/instance implements the specified behavior for blob + // splitting and a meaningful result can be expected from the + // [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // operation. + bool split_blob_support = 9; + + // Whether blob splicing is supported for the particular server/instance. If + // yes, the server/instance implements the specified behavior for blob + // splicing and a meaningful result can be expected from the + // [ContentAddressableStorage.SpliceBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SpliceBlob] + // operation. + bool splice_blob_support = 10; + + // The parameters for the FastCDC 2020 chunking algorithm. + // If set, the server supports the FastCDC chunking algorithm. + FastCdc2020Params fast_cdc_2020_params = 11; + + // The parameters for the RepMaxCDC chunking algorithm. + // If set, the server supports the RepMaxCDC chunking algorithm. + RepMaxCdcParams rep_max_cdc_params = 12; +} + +// Parameters for the FastCDC content-defined chunking algorithm. +// +// Implementations MUST follow the FastCDC 2020 paper by Wen Xia, et al.: +// https://ieeexplore.ieee.org/document/9055082 +// +// Supported implementations: +// - Rust: https://docs.rs/fastcdc/3.2.1/fastcdc/v2020/index.html +// - Go: https://github.com/buildbuddy-io/fastcdc2020 +// +// Test vectors can be found in the accompanying fastcdc2020_test_vectors.txt file. +// +// Implementations MUST use normalization level 2, which has been found +// successful for build artifacts with an average chunk size of 512 KiB. +// +// Key algorithm components from the paper: +// +// GEAR table: 256 64-bit integers for the rolling hash, computed as: +// GEAR[i] = high_64_bits(MD5(byte(i))) for i in 0..255 +// +// MASKS table: Bit patterns for chunk boundary detection, derived from +// the C reference implementation. The mask selection based on average +// chunk size SHOULD match the paper. +// +// The minimum and maximum chunk sizes MUST be derived from the average: +// - min_chunk_size = avg_chunk_size_bytes / 4 +// - max_chunk_size = avg_chunk_size_bytes * 4 +// +// Blobs smaller than max_chunk_size (avg_chunk_size_bytes * 4) SHOULD be +// uploaded without chunking. +// +// If any of the advertised parameters are not within the expected range, +// the client SHOULD ignore FastCDC chunking function support. +message FastCdc2020Params { + // The average (expected) chunk size for the FastCDC chunking algorithm. + // The value MUST be between 1 KiB and 1 MiB. The recommended value is + // 524288 (512 KiB). + uint64 avg_chunk_size_bytes = 1; + + // The seed for the FastCDC mask generation. + // The recommended value is 0. + // + // All clients sharing a cache SHOULD use the same seed to maximize + // chunk reuse. + uint32 seed = 2; +} + +// Parameters for the RepMaxCDC content-defined chunking algorithm. +// +// Supported implementations: +// - Go: https://github.com/buildbarn/go-cdc +// +// Key algorithm components: +// +// GEAR table: 256 64-bit integers for the rolling hash, computed as: +// GEAR[i] = high_64_bits(MD5(byte(i))) for i in 0..255 +// +// The algorithm repeatedly applies chunking until all chunks are in the +// range [min_chunk_size_bytes, 2*min_chunk_size_bytes). Cutting points are +// selected where the Gear rolling hash is maximized within a lookahead +// window of horizon_size_bytes. +// +// If any of the advertised parameters are not within the expected range, +// the client SHOULD ignore RepMaxCDC chunking function support. +message RepMaxCdcParams { + // The minimum chunk size for the RepMaxCDC chunking algorithm. + // The value MUST be at least 64 bytes (the Gear hash window size). + // All chunks will be in the range [min_chunk_size_bytes, 2*min_chunk_size_bytes). + // The recommended value is 262144 (256 KiB). + uint64 min_chunk_size_bytes = 1; + + // The lookahead window for finding optimal cutting points. + // Larger values improve deduplication quality with diminishing returns. + // Setting to 0 produces uniform chunks of min_chunk_size_bytes. + // The recommended value is 8 * min_chunk_size_bytes. + uint64 horizon_size_bytes = 2; +} + +// Capabilities of the remote execution system. +message ExecutionCapabilities { + // Legacy field for indicating which digest function is supported by the + // remote execution system. It MUST be set to a value other than UNKNOWN. + // Implementations should consider the repeated digest_functions field + // first, falling back to this singular field if digest_functions is unset. + DigestFunction.Value digest_function = 1; + + // Whether remote execution is enabled for the particular server/instance. + bool exec_enabled = 2; + + // Supported execution priority range. + PriorityCapabilities execution_priority_capabilities = 3; + + // Supported node properties. + repeated string supported_node_properties = 4; + + // All the digest functions supported by the remote execution system. + // If this field is set, it MUST also contain digest_function. + // + // Even if the remote execution system announces support for multiple + // digest functions, individual execution requests may only reference + // CAS objects using a single digest function. For example, it is not + // permitted to execute actions having both MD5 and SHA-256 hashed + // files in their input root. + // + // The CAS objects referenced by action results generated by the + // remote execution system MUST use the same digest function as the + // one used to construct the action. + repeated DigestFunction.Value digest_functions = 5; +} + +// Details for the tool used to call the API. +message ToolDetails { + // Name of the tool, e.g. bazel. + string tool_name = 1; + + // Version of the tool used for the request, e.g. 5.0.3. + string tool_version = 2; +} + +// An optional Metadata to attach to any RPC request to tell the server about an +// external context of the request. The server may use this for logging or other +// purposes. To use it, the client attaches the header to the call using the +// canonical proto serialization: +// +// * name: `build.bazel.remote.execution.v2.requestmetadata-bin` +// * contents: the base64 encoded binary `RequestMetadata` message. +// Note: the gRPC library serializes binary headers encoded in base64 by +// default (https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests). +// Therefore, if the gRPC library is used to pass/retrieve this +// metadata, the user may ignore the base64 encoding and assume it is simply +// serialized as a binary message. +message RequestMetadata { + // The details for the tool invoking the requests. + ToolDetails tool_details = 1; + + // An identifier that ties multiple requests to the same action. + // For example, multiple requests to the CAS, Action Cache, and Execution + // API are used in order to compile foo.cc. + string action_id = 2; + + // An identifier that ties multiple actions together to a final result. + // For example, multiple actions are required to build and run foo_test. + string tool_invocation_id = 3; + + // An identifier to tie multiple tool invocations together. For example, + // runs of foo_test, bar_test and baz_test on a post-submit of a given patch. + string correlated_invocations_id = 4; + + // A brief description of the kind of action, for example, CppCompile or GoLink. + // There is no standard agreed set of values for this, and they are expected to vary between different client tools. + string action_mnemonic = 5; + + // An identifier for the target which produced this action. + // No guarantees are made around how many actions may relate to a single target. + string target_id = 6; + + // An identifier for the configuration in which the target was built, + // e.g. for differentiating building host tools or different target platforms. + // There is no expectation that this value will have any particular structure, + // or equality across invocations, though some client tools may offer these guarantees. + string configuration_id = 7; +} diff --git a/proto/build/bazel/semver/semver.proto b/proto/build/bazel/semver/semver.proto new file mode 100644 index 0000000..44f83f8 --- /dev/null +++ b/proto/build/bazel/semver/semver.proto @@ -0,0 +1,41 @@ +// Copyright 2018 The Bazel Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package build.bazel.semver; + +option csharp_namespace = "Build.Bazel.Semver"; +option go_package = "github.com/bazelbuild/remote-apis/build/bazel/semver"; +option java_multiple_files = true; +option java_outer_classname = "SemverProto"; +option java_package = "build.bazel.semver"; +option objc_class_prefix = "SMV"; + +// The full version of a given tool. +message SemVer { + // The major version, e.g 10 for 10.2.3. + int32 major = 1; + + // The minor version, e.g. 2 for 10.2.3. + int32 minor = 2; + + // The patch version, e.g 3 for 10.2.3. + int32 patch = 3; + + // The pre-release version. Either this field or major/minor/patch fields + // must be filled. They are mutually exclusive. Pre-release versions are + // assumed to be earlier than any released versions. + string prerelease = 4; +} diff --git a/scripts/generate-proto.sh b/scripts/generate-proto.sh new file mode 100755 index 0000000..0a7d4bd --- /dev/null +++ b/scripts/generate-proto.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Regenerates internal/proto/gen from the vendored protocol buffer definitions in +# proto/. The generated Go code is committed, so this script only needs to run when +# the definitions or the generator versions change. +# +# Pass --update to also re-download the vendored upstream definitions. + +project_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) + +# Keep protoc_gen_go_version in sync with google.golang.org/protobuf in go.mod and +# grpc_version in sync with google.golang.org/grpc. +buf_version=v1.73.0 +protoc_gen_go_version=v1.36.11 +protoc_gen_go_grpc_version=v1.5.1 + +# bazelbuild/remote-apis tag v2.12.0. +remote_apis_revision=9e084d0e43e717128ee72b5be584a7ba33e8006b +remote_apis_files=( + build/bazel/remote/execution/v2/remote_execution.proto + build/bazel/semver/semver.proto +) + +tool_dir="$project_dir/.tools/bin" +mkdir -p "$tool_dir" + +install_tool() { + local binary=$1 module=$2 + if [[ ! -x "$tool_dir/$binary" ]]; then + echo "installing $module" >&2 + GOBIN="$tool_dir" go install "$module" + fi +} + +install_tool buf "github.com/bufbuild/buf/cmd/buf@$buf_version" +install_tool protoc-gen-go "google.golang.org/protobuf/cmd/protoc-gen-go@$protoc_gen_go_version" +install_tool protoc-gen-go-grpc "google.golang.org/grpc/cmd/protoc-gen-go-grpc@$protoc_gen_go_grpc_version" + +export PATH="$tool_dir:$PATH" + +if [[ "${1:-}" == "--update" ]]; then + for file in "${remote_apis_files[@]}"; do + mkdir -p "$project_dir/proto/$(dirname "$file")" + curl -fsSL -o "$project_dir/proto/$file" \ + "https://raw.githubusercontent.com/bazelbuild/remote-apis/$remote_apis_revision/$file" + done + (cd "$project_dir/proto" && buf dep update) +fi + +cd "$project_dir" +rm -rf internal/proto/gen +buf generate +gofmt -l internal/proto/gen From 23d5c9b430922daddfb0760e9b5d0b604b093625 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 21 Sep 2026 00:41:19 +1000 Subject: [PATCH 07/55] Generalise HTTP server in preparation for gRPC support (#9) --- internal/server/objects.go | 246 ++++++++++++++++++++++++++++++++++ internal/server/server.go | 266 ++++++------------------------------- 2 files changed, 287 insertions(+), 225 deletions(-) create mode 100644 internal/server/objects.go diff --git a/internal/server/objects.go b/internal/server/objects.go new file mode 100644 index 0000000..556338a --- /dev/null +++ b/internal/server/objects.go @@ -0,0 +1,246 @@ +package server + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "errors" + "io" + "os" +) + +// Transport-neutral outcomes of a cache operation. Cache policy — the fail-open +// decision, statistics, and redacted logging — is applied by the operations +// below so that every transport behaves identically; a transport only maps these +// onto its own status vocabulary. +var ( + errCacheMiss = errors.New("cache miss") + errBackendFailure = errors.New("cache backend unavailable") + errLocalFailure = errors.New("local cache unavailable") + errPayloadMismatch = errors.New("payload does not match the requested digest") + errPayloadTruncated = errors.New("payload size does not match the declared length") +) + +func (s *Server) objectKey(kind, digest string) string { + return s.cfg.KeyPrefix + "-" + kind + "-" + digest +} + +// degrade reports a backend failure as a miss when the server is fail-open, so +// that a cache outage slows a build down instead of breaking it. +func (s *Server) degrade(failure error) error { + if s.cfg.FailOpen { + s.stats.misses.Add(1) + return errCacheMiss + } + return failure +} + +// readObject resolves an object and, for action results, validates that its CAS +// closure is still complete. +func (s *Server) readObject(ctx context.Context, kind, digest string) (object, error) { + obj, found, err := s.resolve(ctx, s.objectKey(kind, digest), kind, digest) + if err != nil { + s.stats.backendLoadErrors.Add(1) + s.cfg.Logger.Printf("backend load failed for %s/%s: %s", kind, digest, safeError(err)) + return object{}, s.degrade(errBackendFailure) + } + if !found { + s.stats.misses.Add(1) + return object{}, errCacheMiss + } + if kind == "ac" { + if err := s.validateStoredActionResult(ctx, digest, obj); err != nil { + return object{}, err + } + } + return obj, nil +} + +// openObject resolves an object and opens it for serving. The caller closes the +// returned file. A successful call counts a cache hit. +func (s *Server) openObject(ctx context.Context, kind, digest string) (*os.File, int64, error) { + obj, err := s.readObject(ctx, kind, digest) + if err != nil { + return nil, 0, err + } + file, err := os.Open(obj.path) + if err != nil { + s.stats.backendLoadErrors.Add(1) + s.cfg.Logger.Printf("open local cache object %s/%s: %v", kind, digest, err) + if s.cfg.FailOpen { + s.stats.misses.Add(1) + return nil, 0, errCacheMiss + } + return nil, 0, errLocalFailure + } + s.stats.hits.Add(1) + return file, obj.size, nil +} + +// casPresence answers a presence probe from the manifest view when the storage +// mode allows it. Bazel issues these while building without needing the bytes, +// so restoring a whole pack to answer one would defeat the point. +func (s *Server) casPresence(ctx context.Context, digest string) (int64, error) { + size, found, err := s.presence(ctx, s.objectKey("cas", digest)) + if err != nil { + s.cfg.Logger.Printf("presence check for cas/%s failed: %s", digest, safeError(err)) + } + if err != nil || !found { + s.stats.misses.Add(1) + return 0, errCacheMiss + } + s.stats.hits.Add(1) + return size, nil +} + +func (s *Server) validateStoredActionResult(ctx context.Context, digest string, obj object) error { + err := s.validateActionResult(ctx, obj) + switch { + case err == nil: + s.stats.validatedActionResults.Add(1) + return nil + case errors.Is(err, errIncompleteActionResult): + s.stats.incompleteActionResults.Add(1) + s.stats.misses.Add(1) + s.cfg.Logger.Printf("action result ac/%s is incomplete: %s", digest, safeError(err)) + return errCacheMiss + case errors.Is(err, errInvalidActionResult): + s.stats.invalidActionResults.Add(1) + s.stats.misses.Add(1) + s.cfg.Logger.Printf("action result ac/%s is invalid: %s", digest, safeError(err)) + return errCacheMiss + default: + s.stats.backendLoadErrors.Add(1) + s.cfg.Logger.Printf("action result ac/%s validation failed: %s", digest, safeError(err)) + return s.degrade(errBackendFailure) + } +} + +// writeObject spools a payload, verifies it against the requested digest, and +// publishes it when writes are enabled. A nil error only means the caller's +// request was well formed: cache-side failures are absorbed by the fail-open +// policy and reported through the statistics instead. +func (s *Server) writeObject( + ctx context.Context, + kind, digest string, + body io.Reader, + size int64, +) error { + file, err := os.CreateTemp(s.cfg.CacheDir, "upload-*") + if err != nil { + s.cfg.Logger.Printf("create upload spool for %s/%s: %v", kind, digest, err) + return errLocalFailure + } + path := file.Name() + keep := false + defer func() { + _ = file.Close() + if !keep { + _ = os.Remove(path) + } + }() + + hasher := sha256.New() + writer := io.Writer(file) + if kind == "cas" { + writer = io.MultiWriter(file, hasher) + } + n, err := io.Copy(writer, io.LimitReader(body, size+1)) + s.stats.bytesReceived.Add(uint64(n)) + if err != nil || n != size { + return errPayloadTruncated + } + if kind == "cas" && hex.EncodeToString(hasher.Sum(nil)) != digest { + return errPayloadMismatch + } + if err := file.Sync(); err != nil { + s.cfg.Logger.Printf("sync upload spool for %s/%s: %v", kind, digest, err) + return errLocalFailure + } + + key := s.objectKey(kind, digest) + s.objectsMu.Lock() + stored, exists := s.objects[key] + if !exists { + stored = object{path: path, size: n} + s.objects[key] = stored + keep = true + } + s.objectsMu.Unlock() + + if !s.cfg.WriteEnabled { + s.stats.discardedUploads.Add(1) + return nil + } + if s.packs != nil { + return s.stagePacked(ctx, kind, digest, stored) + } + if kind == "ac" { + if err := s.validateActionResultForPublication(ctx, object{path: path, size: n}); err != nil { + return s.absorbActionResultFailure(digest, "publishing", err) + } + s.stats.validatedActionResults.Add(1) + } + + deduplicated, err := s.publishOnce(ctx, key, file, n) + if err != nil { + return s.absorbSaveFailure(kind, digest, err) + } + if deduplicated { + s.stats.deduplicatedUploads.Add(1) + } else { + s.stats.uploads.Add(1) + } + return nil +} + +// stagePacked hands an upload to the CARv2 pack writer, which publishes it as +// part of a later batch rather than as its own backend entry. +func (s *Server) stagePacked(ctx context.Context, kind, digest string, stored object) error { + if kind == "cas" { + s.packs.stageCAS(digest, stored) + return nil + } + closure, err := s.collectActionResultClosure(ctx, stored) + if err != nil { + return s.absorbActionResultFailure(digest, "staging", err) + } + if err := s.packs.stageAction(digest, stored, closure); err != nil { + return s.absorbSaveFailure(kind, digest, err) + } + s.stats.validatedActionResults.Add(1) + return nil +} + +// absorbActionResultFailure drops an action result that must not be published. +// The upload still succeeds from the client's point of view, because a build +// should not fail merely because its result was not cacheable. +func (s *Server) absorbActionResultFailure(digest, stage string, err error) error { + switch { + case errors.Is(err, errIncompleteActionResult): + s.stats.incompleteActionResults.Add(1) + s.stats.skippedActionResultUploads.Add(1) + s.cfg.Logger.Printf("not %s incomplete action result ac/%s: %s", stage, digest, safeError(err)) + case errors.Is(err, errInvalidActionResult): + s.stats.invalidActionResults.Add(1) + s.stats.skippedActionResultUploads.Add(1) + s.cfg.Logger.Printf("not %s invalid action result ac/%s: %s", stage, digest, safeError(err)) + default: + s.stats.backendLoadErrors.Add(1) + s.cfg.Logger.Printf("action result ac/%s failed validation while %s: %s", digest, stage, safeError(err)) + if !s.cfg.FailOpen { + return errBackendFailure + } + s.stats.skippedActionResultUploads.Add(1) + } + return nil +} + +func (s *Server) absorbSaveFailure(kind, digest string, err error) error { + s.stats.backendSaveErrors.Add(1) + s.cfg.Logger.Printf("backend save failed for %s/%s: %s", kind, digest, safeError(err)) + if s.cfg.FailOpen { + return nil + } + return errBackendFailure +} diff --git a/internal/server/server.go b/internal/server/server.go index 1be7d84..abbb897 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -218,48 +218,43 @@ func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) { s.handleImplicitEmptyCASRead(w, r) return } - key := s.cfg.KeyPrefix + "-" + kind + "-" + digest switch r.Method { case http.MethodHead: - s.handleHead(w, r, key, kind, digest) + s.handleHead(w, r, kind, digest) case http.MethodGet: - s.handleRead(w, r, key, kind, digest) + s.handleRead(w, r, kind, digest) case http.MethodPut: - s.handlePut(w, r, key, kind, digest) + s.handlePut(w, r, kind, digest) default: w.Header().Set("Allow", "GET, HEAD, PUT") s.reject(w, "method not allowed", http.StatusMethodNotAllowed) } } -// handleHead answers a packed CAS presence check from the manifest view. -// Bazel issues these while building without the bytes, so restoring a whole -// pack to answer one would defeat the point. -func (s *Server) handleHead(w http.ResponseWriter, r *http.Request, key, kind, digest string) { +// handleHead answers a packed CAS presence check from the manifest view. Bazel +// issues these while building without the bytes, so restoring a whole pack to +// answer one would defeat the point. +func (s *Server) handleHead(w http.ResponseWriter, r *http.Request, kind, digest string) { if s.packs == nil || kind != "cas" { - s.handleRead(w, r, key, kind, digest) + s.handleRead(w, r, kind, digest) return } - size, found, err := s.presence(r.Context(), key) - if err != nil || !found { - if err != nil { - s.cfg.Logger.Printf("presence check for cas/%s failed: %s", digest, safeError(err)) - } - s.stats.misses.Add(1) + size, err := s.casPresence(r.Context(), digest) + if err != nil { http.NotFound(w, r) return } - s.stats.hits.Add(1) - w.Header().Set("Content-Type", "application/octet-stream") - w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) - w.Header().Set("Cache-Control", "private, max-age=31536000, immutable") - w.WriteHeader(http.StatusOK) + s.writeObjectHeader(w, size) } func (s *Server) handleImplicitEmptyCASRead(w http.ResponseWriter, r *http.Request) { s.stats.hits.Add(1) + s.writeObjectHeader(w, 0) +} + +func (s *Server) writeObjectHeader(w http.ResponseWriter, size int64) { w.Header().Set("Content-Type", "application/octet-stream") - w.Header().Set("Content-Length", "0") + w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) w.Header().Set("Cache-Control", "private, max-age=31536000, immutable") w.WriteHeader(http.StatusOK) } @@ -297,71 +292,15 @@ func parseObjectPath(path string) (kind, digest string, ok bool) { return parts[0], parts[1], true } -func (s *Server) handleRead(w http.ResponseWriter, r *http.Request, key, kind, digest string) { - obj, found, err := s.resolve(r.Context(), key, kind, digest) - if err != nil { - s.stats.backendLoadErrors.Add(1) - s.cfg.Logger.Printf("backend load failed for %s/%s: %s", kind, digest, safeError(err)) - if s.cfg.FailOpen { - s.stats.misses.Add(1) - http.NotFound(w, r) - } else { - http.Error(w, "cache backend unavailable", http.StatusBadGateway) - } - return - } - if !found { - s.stats.misses.Add(1) - http.NotFound(w, r) - return - } - if kind == "ac" { - if err := s.validateActionResult(r.Context(), obj); err != nil { - switch { - case errors.Is(err, errIncompleteActionResult): - s.stats.incompleteActionResults.Add(1) - s.stats.misses.Add(1) - s.cfg.Logger.Printf("action result ac/%s is incomplete: %s", digest, safeError(err)) - http.NotFound(w, r) - case errors.Is(err, errInvalidActionResult): - s.stats.invalidActionResults.Add(1) - s.stats.misses.Add(1) - s.cfg.Logger.Printf("action result ac/%s is invalid: %s", digest, safeError(err)) - http.NotFound(w, r) - default: - s.stats.backendLoadErrors.Add(1) - s.cfg.Logger.Printf("action result ac/%s validation failed: %s", digest, safeError(err)) - if s.cfg.FailOpen { - s.stats.misses.Add(1) - http.NotFound(w, r) - } else { - http.Error(w, "cache backend unavailable", http.StatusBadGateway) - } - } - return - } - s.stats.validatedActionResults.Add(1) - } - - file, err := os.Open(obj.path) +func (s *Server) handleRead(w http.ResponseWriter, r *http.Request, kind, digest string) { + file, size, err := s.openObject(r.Context(), kind, digest) if err != nil { - s.stats.backendLoadErrors.Add(1) - s.cfg.Logger.Printf("open local cache object %s/%s: %v", kind, digest, err) - if s.cfg.FailOpen { - s.stats.misses.Add(1) - http.NotFound(w, r) - } else { - http.Error(w, "local cache unavailable", http.StatusInternalServerError) - } + s.failRequest(w, r, err) return } defer file.Close() - s.stats.hits.Add(1) - w.Header().Set("Content-Type", "application/octet-stream") - w.Header().Set("Content-Length", strconv.FormatInt(obj.size, 10)) - w.Header().Set("Cache-Control", "private, max-age=31536000, immutable") - w.WriteHeader(http.StatusOK) + s.writeObjectHeader(w, size) if r.Method == http.MethodHead { return } @@ -372,6 +311,17 @@ func (s *Server) handleRead(w http.ResponseWriter, r *http.Request, key, kind, d } } +func (s *Server) failRequest(w http.ResponseWriter, r *http.Request, err error) { + switch { + case errors.Is(err, errCacheMiss): + http.NotFound(w, r) + case errors.Is(err, errLocalFailure): + http.Error(w, "local cache unavailable", http.StatusInternalServerError) + default: + http.Error(w, "cache backend unavailable", http.StatusBadGateway) + } +} + func (s *Server) resolve(ctx context.Context, key, kind, digest string) (object, bool, error) { s.objectsMu.RLock() obj, ok := s.objects[key] @@ -482,7 +432,7 @@ func (s *Server) backendExists(ctx context.Context, key string) (bool, error) { return s.cfg.Backend.Exists(backendCtx, key) } -func (s *Server) handlePut(w http.ResponseWriter, r *http.Request, key, kind, digest string) { +func (s *Server) handlePut(w http.ResponseWriter, r *http.Request, kind, digest string) { if encoding := r.Header.Get("Content-Encoding"); encoding != "" && !strings.EqualFold(encoding, "identity") { s.reject(w, "content encoding is unsupported", http.StatusUnsupportedMediaType) return @@ -496,141 +446,17 @@ func (s *Server) handlePut(w http.ResponseWriter, r *http.Request, key, kind, di return } - file, err := os.CreateTemp(s.cfg.CacheDir, "upload-*") - if err != nil { - http.Error(w, "cannot create upload spool", http.StatusInternalServerError) - return - } - path := file.Name() - keep := false - defer func() { - _ = file.Close() - if !keep { - _ = os.Remove(path) - } - }() - - hasher := sha256.New() - writer := io.Writer(file) - if kind == "cas" { - writer = io.MultiWriter(file, hasher) - } - n, err := io.Copy(writer, io.LimitReader(r.Body, r.ContentLength+1)) - s.stats.bytesReceived.Add(uint64(n)) - if err != nil { - s.reject(w, "failed to read request body", http.StatusBadRequest) - return - } - if n != r.ContentLength { - s.reject(w, "body size does not match Content-Length", http.StatusBadRequest) - return - } - if kind == "cas" { - actual := hex.EncodeToString(hasher.Sum(nil)) - if actual != digest { - s.reject(w, "CAS digest does not match request body", http.StatusUnprocessableEntity) - return - } - } - if err := file.Sync(); err != nil { - http.Error(w, "cannot sync upload spool", http.StatusInternalServerError) - return - } - - s.objectsMu.Lock() - stored, exists := s.objects[key] - if !exists { - stored = object{path: path, size: n} - s.objects[key] = stored - keep = true - } - s.objectsMu.Unlock() - - if !s.cfg.WriteEnabled { - s.stats.discardedUploads.Add(1) - w.WriteHeader(http.StatusNoContent) - return - } - if s.packs != nil { - if kind == "cas" { - s.packs.stageCAS(digest, stored) - } else { - closure, err := s.collectActionResultClosure(r.Context(), stored) - if err != nil { - s.handlePackedActionValidationError(w, digest, err) - return - } - if err := s.packs.stageAction(digest, stored, closure); err != nil { - s.handleSaveError(w, kind, digest, err) - return - } - s.stats.validatedActionResults.Add(1) - } - w.WriteHeader(http.StatusNoContent) - return - } - if kind == "ac" { - if err := s.validateActionResultForPublication(r.Context(), object{path: path, size: n}); err != nil { - switch { - case errors.Is(err, errIncompleteActionResult): - s.stats.incompleteActionResults.Add(1) - s.stats.skippedActionResultUploads.Add(1) - s.cfg.Logger.Printf("not publishing incomplete action result ac/%s: %s", digest, safeError(err)) - w.WriteHeader(http.StatusNoContent) - case errors.Is(err, errInvalidActionResult): - s.stats.invalidActionResults.Add(1) - s.stats.skippedActionResultUploads.Add(1) - s.cfg.Logger.Printf("not publishing invalid action result ac/%s: %s", digest, safeError(err)) - w.WriteHeader(http.StatusNoContent) - default: - s.stats.backendLoadErrors.Add(1) - s.cfg.Logger.Printf("action result ac/%s publication validation failed: %s", digest, safeError(err)) - if s.cfg.FailOpen { - s.stats.skippedActionResultUploads.Add(1) - w.WriteHeader(http.StatusNoContent) - } else { - http.Error(w, "cache backend unavailable", http.StatusBadGateway) - } - } - return - } - s.stats.validatedActionResults.Add(1) - } - - deduplicated, err := s.publishOnce(r.Context(), key, file, n) - if err != nil { - s.handleSaveError(w, kind, digest, err) - return - } - if deduplicated { - s.stats.deduplicatedUploads.Add(1) - } else { - s.stats.uploads.Add(1) - } - w.WriteHeader(http.StatusNoContent) -} - -func (s *Server) handlePackedActionValidationError(w http.ResponseWriter, digest string, err error) { - switch { - case errors.Is(err, errIncompleteActionResult): - s.stats.incompleteActionResults.Add(1) - s.stats.skippedActionResultUploads.Add(1) - s.cfg.Logger.Printf("not staging incomplete action result ac/%s: %s", digest, safeError(err)) - w.WriteHeader(http.StatusNoContent) - case errors.Is(err, errInvalidActionResult): - s.stats.invalidActionResults.Add(1) - s.stats.skippedActionResultUploads.Add(1) - s.cfg.Logger.Printf("not staging invalid action result ac/%s: %s", digest, safeError(err)) + switch err := s.writeObject(r.Context(), kind, digest, r.Body, r.ContentLength); { + case err == nil: w.WriteHeader(http.StatusNoContent) + case errors.Is(err, errPayloadTruncated): + s.reject(w, "body size does not match Content-Length", http.StatusBadRequest) + case errors.Is(err, errPayloadMismatch): + s.reject(w, "CAS digest does not match request body", http.StatusUnprocessableEntity) + case errors.Is(err, errLocalFailure): + http.Error(w, "cannot spool upload", http.StatusInternalServerError) default: - s.stats.backendLoadErrors.Add(1) - s.cfg.Logger.Printf("packed action result ac/%s validation failed: %s", digest, safeError(err)) - if s.cfg.FailOpen { - s.stats.skippedActionResultUploads.Add(1) - w.WriteHeader(http.StatusNoContent) - } else { - http.Error(w, "cache backend unavailable", http.StatusBadGateway) - } + http.Error(w, "cache backend unavailable", http.StatusBadGateway) } } @@ -698,16 +524,6 @@ func (s *Server) publish(ctx context.Context, key string, file *os.File, size in return s.cfg.Backend.Save(backendCtx, key, file, size) } -func (s *Server) handleSaveError(w http.ResponseWriter, kind, digest string, err error) { - s.stats.backendSaveErrors.Add(1) - s.cfg.Logger.Printf("backend save failed for %s/%s: %s", kind, digest, safeError(err)) - if s.cfg.FailOpen { - w.WriteHeader(http.StatusNoContent) - return - } - http.Error(w, "cache backend unavailable", http.StatusBadGateway) -} - func (s *Server) reject(w http.ResponseWriter, message string, status int) { s.stats.rejectedRequests.Add(1) http.Error(w, message, status) From f356c1de980113e9870abb70070a390f50ebd3a8 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 21 Sep 2026 00:41:20 +1000 Subject: [PATCH 08/55] Support gRPC transport (#11) - gRPC can now be used in conjunction with HTTP - New stat `operations` tracks operations triggered by HTTP and gRPC calls. For identical builds using different transports, these should be able the same. - New stat `backend_requests` to measure traffic hitting GH (which has a quota that a high request volume can exhaust). --- CONTRIBUTING.md | 3 +- README.md | 53 +- action.yml | 10 +- action/main.js | 25 +- buf.gen.yaml | 12 + cmd/cache-server/main.go | 49 +- go.mod | 12 +- go.sum | 24 +- .../execution/v2/remote_execution.pb.go | 2 +- .../execution/v2/remote_execution_grpc.pb.go | 1721 +++++++++++++++++ .../proto/gen/build/bazel/semver/semver.pb.go | 2 +- .../gen/google/bytestream/bytestream.pb.go | 598 ++++++ .../google/bytestream/bytestream_grpc.pb.go | 334 ++++ internal/server/grpc.go | 195 ++ internal/server/grpc_bytestream.go | 235 +++ internal/server/grpc_cas.go | 296 +++ internal/server/grpc_test.go | 525 +++++ internal/server/objects.go | 28 + internal/server/server.go | 31 +- internal/server/stats.go | 6 + scripts/generate-proto.sh | 2 +- 21 files changed, 4115 insertions(+), 48 deletions(-) create mode 100644 internal/proto/gen/build/bazel/remote/execution/v2/remote_execution_grpc.pb.go create mode 100644 internal/proto/gen/google/bytestream/bytestream.pb.go create mode 100644 internal/proto/gen/google/bytestream/bytestream_grpc.pb.go create mode 100644 internal/server/grpc.go create mode 100644 internal/server/grpc_bytestream.go create mode 100644 internal/server/grpc_cas.go create mode 100644 internal/server/grpc_test.go diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b1fcf32..e71e982 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,8 @@ # Contributing Issues and pull requests are welcome. Keep the adapter small, fail-open by -default, and compatible with Bazel's documented HTTP remote-cache protocol. +default, and compatible with Bazel's documented HTTP and gRPC remote-cache +protocols. Before submitting a change, run every command in the development section of the README. Changes to the Go server require rebuilding both checked-in diff --git a/README.md b/README.md index 3b870bf..3c39b3e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ steps: - name: Test env: - CACHE_URL: ${{ steps.bazel-cache.outputs.url }} + CACHE_URL: ${{ steps.bazel-cache.outputs.grpc-url }} CACHE_WRITABLE: ${{ steps.bazel-cache.outputs.writable }} run: > bazel test //... @@ -43,6 +43,9 @@ steps: --remote_upload_local_results="$CACHE_WRITABLE" ``` +Swap `grpc-url` for `url` to use the HTTP endpoint instead; both serve the same +cache and either can be used without changing anything else. + `write: auto` is deliberately conservative: only a `push` to the repository's default branch publishes entries. Pull requests are read-only by default, and fork pull requests remain read-only even if `write: true` is requested. The @@ -212,19 +215,37 @@ Do not enable Bazel remote-cache compression with this release. | `max-uploads-per-minute` | `180` | Evenly spaced uploads; must be below 200 | | `backend-timeout-seconds` | `300` | Timeout for one GitHub cache operation and initial packed-manifest discovery | | `port` | `0` | Loopback port; zero chooses a free dynamic port | +| `grpc-port` | `0` | Loopback port for the gRPC API; zero chooses a free dynamic port | -The main step outputs `url`, `stats-url`, `writable`, `bazel-args`, and -`initial-stats`. The post step emits `final-stats` and always writes the final -counts to the job summary. Because post steps run after normal job steps, -consume `stats-url` during the job if a later step must assert statistics. +The main step outputs `url`, `grpc-url`, `stats-url`, `writable`, `bazel-args`, +`grpc-bazel-args`, and `initial-stats`. The post step emits `final-stats` and +always writes the final counts to the job summary. Because post steps run after +normal job steps, consume `stats-url` during the job if a later step must assert +statistics. ## Protocol support -Supported: +The adapter serves two endpoints from one process against one cache: HTTP on +`url` and gRPC on `grpc-url`. Point Bazel at either with `--remote_cache`. The +gRPC endpoint is the faster of the two because `FindMissingBlobs` settles a +whole input closure in one call, where HTTP needs a `HEAD` per blob. + +Supported over HTTP: - `GET`, `HEAD`, and `PUT` on exactly `/cas/` - `GET`, `HEAD`, and `PUT` on exactly `/ac/` - mandatory `Content-Length` and identity encoding + +Supported over gRPC: + +- `ContentAddressableStorage.FindMissingBlobs`, `BatchUpdateBlobs`, + `BatchReadBlobs`, and `GetTree` +- `ActionCache.GetActionResult` and `UpdateActionResult` +- `Capabilities.GetCapabilities` +- `ByteStream.Read` and `Write` for blobs above the 4 MiB batch limit + +Supported by both: + - CAS SHA-256 verification before publication and after download - structural validation of REAPI `ActionResult`, `Tree`, and `Directory` messages @@ -232,15 +253,16 @@ Supported: - AC publication only after every referenced CAS object is persistent - implicit handling of the standard SHA-256 zero-byte CAS digest - immutable cache keys -- per-job coalescing of duplicate immutable `PUT`s before rate limiting and backend publication +- per-job coalescing of duplicate immutable uploads before rate limiting and backend publication - opt-in CARv2 archives with footer indexes, DAG-CBOR manifests, concurrent writer head merging, and action-result conflict detection Not currently supported: -- Bazel `instance_name` path prefixes -- HTTP or zstd remote-cache compression -- gRPC or remote execution +- Bazel `instance_name` prefixes; a non-empty one is rejected rather than ignored +- HTTP or zstd remote-cache compression, including `compressed-blobs` resources +- resumable `ByteStream` uploads; `QueryWriteStatus` always reports no progress +- remote execution - range requests - Windows or macOS runners @@ -254,6 +276,17 @@ pack and one for its manifest, so a large build graph is governed by pack count instead of object count. `pack_uploads`, `manifest_uploads`, and `pack_downloads` make that distinction explicit in the final statistics. +Three counters describe load, and they deliberately do not agree: + +| Counter | Counts | Reading it | +| --- | --- | --- | +| `requests` | One per client call: an HTTP request, or a gRPC RPC | Over gRPC this should be far below `operations`; if it is not, the client is not batching | +| `operations` | One per cache object the client asked about | Comparable between HTTP and gRPC, so it measures the build rather than the protocol | +| `backend_requests` | One per call into the GitHub Actions cache | Tracks API pressure and quota risk; closure validation and packed reads raise it without any matching client call | + +Manifest discovery talks to the GitHub REST API instead, under a separate quota, +and is reported by `manifests_discovered` and `packs_discovered`. + GitHub's repository cache quota, eviction policy, and branch restrictions all apply. At the time of writing, the default repository quota is 10 GB and caches not accessed for seven days may be evicted. Pull-request caches are scoped, while diff --git a/action.yml b/action.yml index e97dd15..39d5558 100644 --- a/action.yml +++ b/action.yml @@ -69,15 +69,23 @@ inputs: description: "Loopback port; zero selects an available dynamic port" required: false default: "0" + grpc-port: + description: "Loopback port for the gRPC remote-cache API; zero selects an available dynamic port" + required: false + default: "0" outputs: url: description: "Loopback Bazel HTTP remote-cache URL" + grpc-url: + description: "Loopback Bazel gRPC remote-cache URL" stats-url: description: "Loopback JSON statistics endpoint available until the post-step" writable: description: "Whether validated objects are published to GitHub Actions cache" bazel-args: - description: "Ready-to-use --remote_cache and --remote_upload_local_results flags" + description: "Ready-to-use --remote_cache and --remote_upload_local_results flags for the HTTP endpoint" + grpc-bazel-args: + description: "Ready-to-use --remote_cache and --remote_upload_local_results flags for the gRPC endpoint" initial-stats: description: "Initial statistics JSON" final-stats: diff --git a/action/main.js b/action/main.js index 2c98435..8e32d49 100644 --- a/action/main.js +++ b/action/main.js @@ -34,6 +34,14 @@ function positiveInteger(name, fallback, maximum = Number.MAX_SAFE_INTEGER) { return value; } +function portNumber(name) { + const value = Number.parseInt(input(name, "0"), 10); + if (!Number.isSafeInteger(value) || value < 0 || value > 65535) { + throw new Error(`${name} must be an integer between 0 and 65535`); + } + return value; +} + async function main() { if (process.platform !== "linux") { throw new Error("this release supports Linux GitHub Actions runners only"); @@ -76,10 +84,10 @@ async function main() { throw new Error("storage-mode=packs requires github-token with actions: read"); } if (githubToken) mask(githubToken); - const portText = input("port", "0"); - const port = Number.parseInt(portText, 10); - if (!Number.isSafeInteger(port) || port < 0 || port > 65535) { - throw new Error("port must be an integer between 0 and 65535"); + const port = portNumber("port"); + const grpcPort = portNumber("grpc-port"); + if (port !== 0 && port === grpcPort) { + throw new Error("port and grpc-port must differ"); } const tempDir = safeTemporaryDirectory( @@ -95,6 +103,8 @@ async function main() { const args = [ "--port", String(port), + "--grpc-port", + String(grpcPort), "--cache-dir", spoolDir, "--key-prefix", @@ -167,15 +177,20 @@ async function main() { saveState("temp_dir", tempDir); saveState("shutdown_wait_seconds", String(Math.max(60, backendTimeoutSeconds + 30))); setOutput("url", ready.url); + setOutput("grpc-url", ready.grpc_url); setOutput("stats-url", ready.stats_url); setOutput("writable", String(writeEnabled)); setOutput( "bazel-args", `--remote_cache=${ready.url} --remote_upload_local_results=${writeEnabled}`, ); + setOutput( + "grpc-bazel-args", + `--remote_cache=${ready.grpc_url} --remote_upload_local_results=${writeEnabled}`, + ); setOutput("initial-stats", '{"requests":0,"hits":0,"misses":0,"uploads":0}'); process.stdout.write( - `Bazel cache adapter ready at ${ready.url} (write=${writeEnabled}, mode=${storageMode}, fail_open=${failOpen}, pid=${ready.pid})${os.EOL}`, + `Bazel cache adapter ready at ${ready.url} and ${ready.grpc_url} (write=${writeEnabled}, mode=${storageMode}, fail_open=${failOpen}, pid=${ready.pid})${os.EOL}`, ); } diff --git a/buf.gen.yaml b/buf.gen.yaml index 891b59e..7568e7e 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,7 +1,11 @@ # Generated code is committed to the repository; run scripts/generate-proto.sh to refresh it. +# The googleapis commit below must match the one pinned in proto/buf.lock. version: v2 inputs: - directory: proto + - module: buf.build/googleapis/googleapis:c17df5b2beca46928cc87d5656bd5343 + paths: + - google/bytestream/bytestream.proto plugins: # google.golang.org/protobuf >= 1.36 opaque API: struct fields are hidden behind # accessors, which lets the runtime pick a more compact in-memory layout. @@ -12,3 +16,11 @@ plugins: - default_api_level=API_OPAQUE - Mbuild/bazel/semver/semver.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/semver;semver - Mbuild/bazel/remote/execution/v2/remote_execution.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2;remoteexecution + - Mgoogle/bytestream/bytestream.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/google/bytestream;bytestream + - local: protoc-gen-go-grpc + out: internal/proto/gen + opt: + - paths=source_relative + - Mbuild/bazel/semver/semver.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/semver;semver + - Mbuild/bazel/remote/execution/v2/remote_execution.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2;remoteexecution + - Mgoogle/bytestream/bytestream.proto=github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/google/bytestream;bytestream diff --git a/cmd/cache-server/main.go b/cmd/cache-server/main.go index e7ae96e..e2cdcd6 100644 --- a/cmd/cache-server/main.go +++ b/cmd/cache-server/main.go @@ -15,6 +15,8 @@ import ( "syscall" "time" + "google.golang.org/grpc" + "github.com/cre4ture/bazel-github-actions-cache-v2/internal/cache" cacheserver "github.com/cre4ture/bazel-github-actions-cache-v2/internal/server" ) @@ -23,6 +25,7 @@ var version = "dev" type readyInfo struct { URL string `json:"url"` + GRPCURL string `json:"grpc_url"` StatsURL string `json:"stats_url"` PID int `json:"pid"` Version string `json:"version"` @@ -38,6 +41,7 @@ func main() { func run() error { var ( port = flag.Int("port", 0, "loopback TCP port; zero selects a dynamic port") + grpcPort = flag.Int("grpc-port", 0, "loopback TCP port for the gRPC remote-cache API; zero selects a dynamic port") cacheDir = flag.String("cache-dir", "", "local spool directory") keyPrefix = flag.String("key-prefix", "bazel-http-v1", "GitHub cache key prefix") storageMode = flag.String("storage-mode", "objects", "storage mode: objects or packs") @@ -84,6 +88,14 @@ func run() error { address := listener.Addr().(*net.TCPAddr) baseURL := "http://127.0.0.1:" + strconv.Itoa(address.Port) + grpcListener, err := net.Listen("tcp4", net.JoinHostPort("127.0.0.1", strconv.Itoa(*grpcPort))) + if err != nil { + return fmt.Errorf("listen on loopback for gRPC: %w", err) + } + defer grpcListener.Close() + grpcAddress := grpcListener.Addr().(*net.TCPAddr) + grpcURL := "grpc://127.0.0.1:" + strconv.Itoa(grpcAddress.Port) + shutdownRequested := make(chan struct{}, 1) requestShutdown := func() { select { @@ -134,17 +146,22 @@ func run() error { IdleTimeout: 90 * time.Second, MaxHeaderBytes: 16 * 1024, } - serveErr := make(chan error, 1) + serveErr := make(chan error, 2) go func() { - err := httpServer.Serve(listener) - if err != nil && err != http.ErrServerClosed { - serveErr <- err + if err := httpServer.Serve(listener); err != nil && err != http.ErrServerClosed { + serveErr <- fmt.Errorf("serve http: %w", err) + } + }() + grpcServer := srv.GRPCHandler() + go func() { + if err := grpcServer.Serve(grpcListener); err != nil && err != grpc.ErrServerStopped { + serveErr <- fmt.Errorf("serve grpc: %w", err) } - close(serveErr) }() ready := readyInfo{ URL: baseURL, + GRPCURL: grpcURL, StatsURL: baseURL + "/stats", PID: os.Getpid(), Version: version, @@ -156,7 +173,7 @@ func run() error { if err := os.WriteFile(*readyFile, append(data, '\n'), 0o600); err != nil { return fmt.Errorf("write ready file: %w", err) } - logger.Printf("ready on %s (write=%t, fail_open=%t)", baseURL, *writeEnabled, *failOpen) + logger.Printf("ready on %s and %s (write=%t, fail_open=%t)", baseURL, grpcURL, *writeEnabled, *failOpen) signals := make(chan os.Signal, 1) signal.Notify(signals, os.Interrupt, syscall.SIGTERM) @@ -167,9 +184,7 @@ func run() error { case <-shutdownRequested: logger.Printf("shutdown requested") case err := <-serveErr: - if err != nil { - return fmt.Errorf("serve: %w", err) - } + return err } ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -178,6 +193,7 @@ func run() error { logger.Printf("graceful shutdown failed: %v", err) _ = httpServer.Close() } + stopGRPC(grpcServer) flushContext, flushCancel := context.WithTimeout(context.Background(), *backendTimeout) if err := srv.Close(flushContext); err != nil { logger.Printf("flush packed cache: %v", err) @@ -190,3 +206,18 @@ func run() error { logger.Printf("stopped: %s", strings.TrimSpace(string(stats.JSON()))) return nil } + +// stopGRPC drains in-flight RPCs, but does not let a stuck stream hold up the +// post step that has to flush the cache before the job ends. +func stopGRPC(server *grpc.Server) { + stopped := make(chan struct{}) + go func() { + server.GracefulStop() + close(stopped) + }() + select { + case <-stopped: + case <-time.After(10 * time.Second): + server.Stop() + } +} diff --git a/go.mod b/go.mod index d62cc07..5c4ad03 100644 --- a/go.mod +++ b/go.mod @@ -14,9 +14,11 @@ require ( require ( cloud.google.com/go/longrunning v1.2.0 github.com/klauspost/compress v1.20.0 + golang.org/x/sync v0.22.0 google.golang.org/genproto/googleapis/api v0.0.0-20260706201446-f0a921348800 google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 - google.golang.org/protobuf v1.36.11 + google.golang.org/grpc v1.83.2 // v1.84.0 is affected by GO-2026-6443; stay on the patched 1.83 line + google.golang.org/protobuf v1.36.12 ) require ( @@ -42,13 +44,11 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect github.com/whyrusleeping/cbor-gen v0.3.1 // indirect - golang.org/x/crypto v0.54.0 // indirect + golang.org/x/crypto v0.55.0 // indirect golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect - golang.org/x/net v0.57.0 // indirect - golang.org/x/sync v0.22.0 // indirect + golang.org/x/net v0.58.0 // indirect golang.org/x/sys v0.47.0 // indirect - golang.org/x/text v0.40.0 // indirect + golang.org/x/text v0.41.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect - google.golang.org/grpc v1.82.0 // indirect lukechampine.com/blake3 v1.4.1 // indirect ) diff --git a/go.sum b/go.sum index 2cabeb8..fc4306b 100644 --- a/go.sum +++ b/go.sum @@ -145,26 +145,26 @@ go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSY go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo= go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58= go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0= -go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw= -go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A= +go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI= +go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA= go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk= go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= -golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= -golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= -golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= +golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= +golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= -golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= @@ -173,10 +173,10 @@ google.golang.org/genproto/googleapis/api v0.0.0-20260706201446-f0a921348800 h1: google.golang.org/genproto/googleapis/api v0.0.0-20260706201446-f0a921348800/go.mod h1:FPk7EXUKMtImne7AmknoYjT4QXqKIzzRbeQIXzLk6fQ= google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 h1:qEHAMpSaUhtD0p3NbEEI83HwNGFxEwaSJ1G9PLnCBZE= google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU= -google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA= -google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= -google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= +google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go b/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go index bc80ff6..ee873fb 100644 --- a/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go +++ b/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 +// protoc-gen-go v1.36.12 // protoc (unknown) // source: build/bazel/remote/execution/v2/remote_execution.proto diff --git a/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution_grpc.pb.go b/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution_grpc.pb.go new file mode 100644 index 0000000..5016c7d --- /dev/null +++ b/internal/proto/gen/build/bazel/remote/execution/v2/remote_execution_grpc.pb.go @@ -0,0 +1,1721 @@ +// Copyright 2018 The Bazel Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: build/bazel/remote/execution/v2/remote_execution.proto + +package remoteexecution + +import ( + longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Execution_Execute_FullMethodName = "/build.bazel.remote.execution.v2.Execution/Execute" + Execution_WaitExecution_FullMethodName = "/build.bazel.remote.execution.v2.Execution/WaitExecution" +) + +// ExecutionClient is the client API for Execution service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The Remote Execution API is used to execute an +// [Action][build.bazel.remote.execution.v2.Action] on the remote +// workers. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +type ExecutionClient interface { + // Execute an action remotely. + // + // In order to execute an action, the client must first upload all of the + // inputs, the + // [Command][build.bazel.remote.execution.v2.Command] to run, and the + // [Action][build.bazel.remote.execution.v2.Action] into the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + // It then calls `Execute` with an `action_digest` referring to them. The + // server will run the action and eventually return the result. + // + // The input `Action`'s fields MUST meet the various canonicalization + // requirements specified in the documentation for their types so that it has + // the same digest as other logically equivalent `Action`s. The server MAY + // enforce the requirements and return errors if a non-canonical input is + // received. It MAY also proceed without verifying some or all of the + // requirements, such as for performance reasons. If the server does not + // verify the requirement, then it will treat the `Action` as distinct from + // another logically equivalent action if they hash differently. + // + // Returns a stream of + // [google.longrunning.Operation][google.longrunning.Operation] messages + // describing the resulting execution, with eventual `response` + // [ExecuteResponse][build.bazel.remote.execution.v2.ExecuteResponse]. The + // `metadata` on the operation is of type + // [ExecuteOperationMetadata][build.bazel.remote.execution.v2.ExecuteOperationMetadata]. + // + // If the client remains connected after the first response is returned after + // the server, then updates are streamed as if the client had called + // [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution] + // until the execution completes or the request reaches an error. The + // operation can also be queried using [Operations + // API][google.longrunning.Operations.GetOperation]. + // + // The server NEED NOT implement other methods or functionality of the + // Operations API. + // + // Errors discovered during creation of the `Operation` will be reported + // as gRPC Status errors, while errors that occurred while running the + // action will be reported in the `status` field of the `ExecuteResponse`. The + // server MUST NOT set the `error` field of the `Operation` proto. + // The possible errors include: + // + // - `INVALID_ARGUMENT`: One or more arguments are invalid. + // - `FAILED_PRECONDITION`: One or more errors occurred in setting up the + // action requested, such as a missing input or command or no worker being + // available. The client may be able to fix the errors and retry. + // - `RESOURCE_EXHAUSTED`: There is insufficient quota of some resource to run + // the action. + // - `UNAVAILABLE`: Due to a transient condition, such as all workers being + // occupied (and the server does not support a queue), the action could not + // be started. The client should retry. + // - `INTERNAL`: An internal error occurred in the execution engine or the + // worker. + // - `DEADLINE_EXCEEDED`: The execution timed out. + // - `CANCELLED`: The operation was cancelled by the client. This status is + // only possible if the server implements the Operations API CancelOperation + // method, and it was called for the current execution. + // + // In the case of a missing input or command, the server SHOULD additionally + // send a [PreconditionFailure][google.rpc.PreconditionFailure] error detail + // where, for each requested blob not present in the CAS, there is a + // `Violation` with a `type` of `MISSING` and a `subject` of + // `"blobs/{digest_function/}{hash}/{size}"` indicating the digest of the + // missing blob. The `subject` is formatted the same way as the + // `resource_name` provided to + // [ByteStream.Read][google.bytestream.ByteStream.Read], with the leading + // instance name omitted. `digest_function` MUST thus be omitted if its value + // is one of MD5, MURMUR3, SHA1, SHA256, SHA384, SHA512, or VSO. + // + // The server does not need to guarantee that a call to this method leads to + // at most one execution of the action. The server MAY execute the action + // multiple times, potentially in parallel. These redundant executions MAY + // continue to run, even if the operation is completed. + Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[longrunningpb.Operation], error) + // Wait for an execution operation to complete. When the client initially + // makes the request, the server immediately responds with the current status + // of the execution. The server will leave the request stream open until the + // operation completes, and then respond with the completed operation. The + // server MAY choose to stream additional updates as execution progresses, + // such as to provide an update as to the state of the execution. + // + // In addition to the cases described for Execute, the WaitExecution method + // may fail as follows: + // + // - `NOT_FOUND`: The operation no longer exists due to any of a transient + // condition, an unknown operation name, or if the server implements the + // Operations API DeleteOperation method and it was called for the current + // execution. The client should call `Execute` to retry. + WaitExecution(ctx context.Context, in *WaitExecutionRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[longrunningpb.Operation], error) +} + +type executionClient struct { + cc grpc.ClientConnInterface +} + +func NewExecutionClient(cc grpc.ClientConnInterface) ExecutionClient { + return &executionClient{cc} +} + +func (c *executionClient) Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[longrunningpb.Operation], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &Execution_ServiceDesc.Streams[0], Execution_Execute_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[ExecuteRequest, longrunningpb.Operation]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Execution_ExecuteClient = grpc.ServerStreamingClient[longrunningpb.Operation] + +func (c *executionClient) WaitExecution(ctx context.Context, in *WaitExecutionRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[longrunningpb.Operation], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &Execution_ServiceDesc.Streams[1], Execution_WaitExecution_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[WaitExecutionRequest, longrunningpb.Operation]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Execution_WaitExecutionClient = grpc.ServerStreamingClient[longrunningpb.Operation] + +// ExecutionServer is the server API for Execution service. +// All implementations must embed UnimplementedExecutionServer +// for forward compatibility. +// +// The Remote Execution API is used to execute an +// [Action][build.bazel.remote.execution.v2.Action] on the remote +// workers. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +type ExecutionServer interface { + // Execute an action remotely. + // + // In order to execute an action, the client must first upload all of the + // inputs, the + // [Command][build.bazel.remote.execution.v2.Command] to run, and the + // [Action][build.bazel.remote.execution.v2.Action] into the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. + // It then calls `Execute` with an `action_digest` referring to them. The + // server will run the action and eventually return the result. + // + // The input `Action`'s fields MUST meet the various canonicalization + // requirements specified in the documentation for their types so that it has + // the same digest as other logically equivalent `Action`s. The server MAY + // enforce the requirements and return errors if a non-canonical input is + // received. It MAY also proceed without verifying some or all of the + // requirements, such as for performance reasons. If the server does not + // verify the requirement, then it will treat the `Action` as distinct from + // another logically equivalent action if they hash differently. + // + // Returns a stream of + // [google.longrunning.Operation][google.longrunning.Operation] messages + // describing the resulting execution, with eventual `response` + // [ExecuteResponse][build.bazel.remote.execution.v2.ExecuteResponse]. The + // `metadata` on the operation is of type + // [ExecuteOperationMetadata][build.bazel.remote.execution.v2.ExecuteOperationMetadata]. + // + // If the client remains connected after the first response is returned after + // the server, then updates are streamed as if the client had called + // [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution] + // until the execution completes or the request reaches an error. The + // operation can also be queried using [Operations + // API][google.longrunning.Operations.GetOperation]. + // + // The server NEED NOT implement other methods or functionality of the + // Operations API. + // + // Errors discovered during creation of the `Operation` will be reported + // as gRPC Status errors, while errors that occurred while running the + // action will be reported in the `status` field of the `ExecuteResponse`. The + // server MUST NOT set the `error` field of the `Operation` proto. + // The possible errors include: + // + // - `INVALID_ARGUMENT`: One or more arguments are invalid. + // - `FAILED_PRECONDITION`: One or more errors occurred in setting up the + // action requested, such as a missing input or command or no worker being + // available. The client may be able to fix the errors and retry. + // - `RESOURCE_EXHAUSTED`: There is insufficient quota of some resource to run + // the action. + // - `UNAVAILABLE`: Due to a transient condition, such as all workers being + // occupied (and the server does not support a queue), the action could not + // be started. The client should retry. + // - `INTERNAL`: An internal error occurred in the execution engine or the + // worker. + // - `DEADLINE_EXCEEDED`: The execution timed out. + // - `CANCELLED`: The operation was cancelled by the client. This status is + // only possible if the server implements the Operations API CancelOperation + // method, and it was called for the current execution. + // + // In the case of a missing input or command, the server SHOULD additionally + // send a [PreconditionFailure][google.rpc.PreconditionFailure] error detail + // where, for each requested blob not present in the CAS, there is a + // `Violation` with a `type` of `MISSING` and a `subject` of + // `"blobs/{digest_function/}{hash}/{size}"` indicating the digest of the + // missing blob. The `subject` is formatted the same way as the + // `resource_name` provided to + // [ByteStream.Read][google.bytestream.ByteStream.Read], with the leading + // instance name omitted. `digest_function` MUST thus be omitted if its value + // is one of MD5, MURMUR3, SHA1, SHA256, SHA384, SHA512, or VSO. + // + // The server does not need to guarantee that a call to this method leads to + // at most one execution of the action. The server MAY execute the action + // multiple times, potentially in parallel. These redundant executions MAY + // continue to run, even if the operation is completed. + Execute(*ExecuteRequest, grpc.ServerStreamingServer[longrunningpb.Operation]) error + // Wait for an execution operation to complete. When the client initially + // makes the request, the server immediately responds with the current status + // of the execution. The server will leave the request stream open until the + // operation completes, and then respond with the completed operation. The + // server MAY choose to stream additional updates as execution progresses, + // such as to provide an update as to the state of the execution. + // + // In addition to the cases described for Execute, the WaitExecution method + // may fail as follows: + // + // - `NOT_FOUND`: The operation no longer exists due to any of a transient + // condition, an unknown operation name, or if the server implements the + // Operations API DeleteOperation method and it was called for the current + // execution. The client should call `Execute` to retry. + WaitExecution(*WaitExecutionRequest, grpc.ServerStreamingServer[longrunningpb.Operation]) error + mustEmbedUnimplementedExecutionServer() +} + +// UnimplementedExecutionServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedExecutionServer struct{} + +func (UnimplementedExecutionServer) Execute(*ExecuteRequest, grpc.ServerStreamingServer[longrunningpb.Operation]) error { + return status.Errorf(codes.Unimplemented, "method Execute not implemented") +} +func (UnimplementedExecutionServer) WaitExecution(*WaitExecutionRequest, grpc.ServerStreamingServer[longrunningpb.Operation]) error { + return status.Errorf(codes.Unimplemented, "method WaitExecution not implemented") +} +func (UnimplementedExecutionServer) mustEmbedUnimplementedExecutionServer() {} +func (UnimplementedExecutionServer) testEmbeddedByValue() {} + +// UnsafeExecutionServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ExecutionServer will +// result in compilation errors. +type UnsafeExecutionServer interface { + mustEmbedUnimplementedExecutionServer() +} + +func RegisterExecutionServer(s grpc.ServiceRegistrar, srv ExecutionServer) { + // If the following call pancis, it indicates UnimplementedExecutionServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Execution_ServiceDesc, srv) +} + +func _Execution_Execute_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ExecuteRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ExecutionServer).Execute(m, &grpc.GenericServerStream[ExecuteRequest, longrunningpb.Operation]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Execution_ExecuteServer = grpc.ServerStreamingServer[longrunningpb.Operation] + +func _Execution_WaitExecution_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(WaitExecutionRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ExecutionServer).WaitExecution(m, &grpc.GenericServerStream[WaitExecutionRequest, longrunningpb.Operation]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Execution_WaitExecutionServer = grpc.ServerStreamingServer[longrunningpb.Operation] + +// Execution_ServiceDesc is the grpc.ServiceDesc for Execution service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Execution_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "build.bazel.remote.execution.v2.Execution", + HandlerType: (*ExecutionServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Execute", + Handler: _Execution_Execute_Handler, + ServerStreams: true, + }, + { + StreamName: "WaitExecution", + Handler: _Execution_WaitExecution_Handler, + ServerStreams: true, + }, + }, + Metadata: "build/bazel/remote/execution/v2/remote_execution.proto", +} + +const ( + ActionCache_GetActionResult_FullMethodName = "/build.bazel.remote.execution.v2.ActionCache/GetActionResult" + ActionCache_UpdateActionResult_FullMethodName = "/build.bazel.remote.execution.v2.ActionCache/UpdateActionResult" +) + +// ActionCacheClient is the client API for ActionCache service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The action cache API is used to query whether a given action has already been +// performed and, if so, retrieve its result. Unlike the +// [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage], +// which addresses blobs by their own content, the action cache addresses the +// [ActionResult][build.bazel.remote.execution.v2.ActionResult] by a +// digest of the encoded [Action][build.bazel.remote.execution.v2.Action] +// which produced them. +// +// The lifetime of entries in the action cache is implementation-specific, but +// the server SHOULD assume that more recently used entries are more likely to +// be used again. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +type ActionCacheClient interface { + // Retrieve a cached execution result. + // + // Implementations SHOULD ensure that any blobs referenced from the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] + // are available at the time of returning the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] and will be + // for some period of time afterwards. The lifetimes of the referenced blobs SHOULD be increased + // if necessary and applicable. + // + // Errors: + // + // * `NOT_FOUND`: The requested `ActionResult` is not in the cache. + GetActionResult(ctx context.Context, in *GetActionResultRequest, opts ...grpc.CallOption) (*ActionResult, error) + // Upload a new execution result. + // + // In order to allow the server to perform access control based on the type of + // action, and to assist with client debugging, the client MUST first upload + // the [Action][build.bazel.remote.execution.v2.Action] that produced the + // result, along with its + // [Command][build.bazel.remote.execution.v2.Command], into the + // `ContentAddressableStorage`. + // + // Server implementations MAY modify the + // `UpdateActionResultRequest.action_result` and return an equivalent value. + // + // Errors: + // + // - `INVALID_ARGUMENT`: One or more arguments are invalid. + // - `FAILED_PRECONDITION`: One or more errors occurred in updating the + // action result, such as a missing command or action. + // - `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the + // entry to the cache. + UpdateActionResult(ctx context.Context, in *UpdateActionResultRequest, opts ...grpc.CallOption) (*ActionResult, error) +} + +type actionCacheClient struct { + cc grpc.ClientConnInterface +} + +func NewActionCacheClient(cc grpc.ClientConnInterface) ActionCacheClient { + return &actionCacheClient{cc} +} + +func (c *actionCacheClient) GetActionResult(ctx context.Context, in *GetActionResultRequest, opts ...grpc.CallOption) (*ActionResult, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ActionResult) + err := c.cc.Invoke(ctx, ActionCache_GetActionResult_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *actionCacheClient) UpdateActionResult(ctx context.Context, in *UpdateActionResultRequest, opts ...grpc.CallOption) (*ActionResult, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ActionResult) + err := c.cc.Invoke(ctx, ActionCache_UpdateActionResult_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ActionCacheServer is the server API for ActionCache service. +// All implementations must embed UnimplementedActionCacheServer +// for forward compatibility. +// +// The action cache API is used to query whether a given action has already been +// performed and, if so, retrieve its result. Unlike the +// [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage], +// which addresses blobs by their own content, the action cache addresses the +// [ActionResult][build.bazel.remote.execution.v2.ActionResult] by a +// digest of the encoded [Action][build.bazel.remote.execution.v2.Action] +// which produced them. +// +// The lifetime of entries in the action cache is implementation-specific, but +// the server SHOULD assume that more recently used entries are more likely to +// be used again. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +type ActionCacheServer interface { + // Retrieve a cached execution result. + // + // Implementations SHOULD ensure that any blobs referenced from the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] + // are available at the time of returning the + // [ActionResult][build.bazel.remote.execution.v2.ActionResult] and will be + // for some period of time afterwards. The lifetimes of the referenced blobs SHOULD be increased + // if necessary and applicable. + // + // Errors: + // + // * `NOT_FOUND`: The requested `ActionResult` is not in the cache. + GetActionResult(context.Context, *GetActionResultRequest) (*ActionResult, error) + // Upload a new execution result. + // + // In order to allow the server to perform access control based on the type of + // action, and to assist with client debugging, the client MUST first upload + // the [Action][build.bazel.remote.execution.v2.Action] that produced the + // result, along with its + // [Command][build.bazel.remote.execution.v2.Command], into the + // `ContentAddressableStorage`. + // + // Server implementations MAY modify the + // `UpdateActionResultRequest.action_result` and return an equivalent value. + // + // Errors: + // + // - `INVALID_ARGUMENT`: One or more arguments are invalid. + // - `FAILED_PRECONDITION`: One or more errors occurred in updating the + // action result, such as a missing command or action. + // - `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the + // entry to the cache. + UpdateActionResult(context.Context, *UpdateActionResultRequest) (*ActionResult, error) + mustEmbedUnimplementedActionCacheServer() +} + +// UnimplementedActionCacheServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedActionCacheServer struct{} + +func (UnimplementedActionCacheServer) GetActionResult(context.Context, *GetActionResultRequest) (*ActionResult, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetActionResult not implemented") +} +func (UnimplementedActionCacheServer) UpdateActionResult(context.Context, *UpdateActionResultRequest) (*ActionResult, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateActionResult not implemented") +} +func (UnimplementedActionCacheServer) mustEmbedUnimplementedActionCacheServer() {} +func (UnimplementedActionCacheServer) testEmbeddedByValue() {} + +// UnsafeActionCacheServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ActionCacheServer will +// result in compilation errors. +type UnsafeActionCacheServer interface { + mustEmbedUnimplementedActionCacheServer() +} + +func RegisterActionCacheServer(s grpc.ServiceRegistrar, srv ActionCacheServer) { + // If the following call pancis, it indicates UnimplementedActionCacheServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ActionCache_ServiceDesc, srv) +} + +func _ActionCache_GetActionResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetActionResultRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ActionCacheServer).GetActionResult(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ActionCache_GetActionResult_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ActionCacheServer).GetActionResult(ctx, req.(*GetActionResultRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ActionCache_UpdateActionResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateActionResultRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ActionCacheServer).UpdateActionResult(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ActionCache_UpdateActionResult_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ActionCacheServer).UpdateActionResult(ctx, req.(*UpdateActionResultRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ActionCache_ServiceDesc is the grpc.ServiceDesc for ActionCache service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ActionCache_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "build.bazel.remote.execution.v2.ActionCache", + HandlerType: (*ActionCacheServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetActionResult", + Handler: _ActionCache_GetActionResult_Handler, + }, + { + MethodName: "UpdateActionResult", + Handler: _ActionCache_UpdateActionResult_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "build/bazel/remote/execution/v2/remote_execution.proto", +} + +const ( + ContentAddressableStorage_FindMissingBlobs_FullMethodName = "/build.bazel.remote.execution.v2.ContentAddressableStorage/FindMissingBlobs" + ContentAddressableStorage_BatchUpdateBlobs_FullMethodName = "/build.bazel.remote.execution.v2.ContentAddressableStorage/BatchUpdateBlobs" + ContentAddressableStorage_BatchReadBlobs_FullMethodName = "/build.bazel.remote.execution.v2.ContentAddressableStorage/BatchReadBlobs" + ContentAddressableStorage_GetTree_FullMethodName = "/build.bazel.remote.execution.v2.ContentAddressableStorage/GetTree" + ContentAddressableStorage_SplitBlob_FullMethodName = "/build.bazel.remote.execution.v2.ContentAddressableStorage/SplitBlob" + ContentAddressableStorage_SpliceBlob_FullMethodName = "/build.bazel.remote.execution.v2.ContentAddressableStorage/SpliceBlob" +) + +// ContentAddressableStorageClient is the client API for ContentAddressableStorage service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The CAS (content-addressable storage) is used to store the inputs to and +// outputs from the execution service. Each piece of content is addressed by the +// digest of its binary data. +// +// Most of the binary data stored in the CAS is opaque to the execution engine, +// and is only used as a communication medium. In order to build an +// [Action][build.bazel.remote.execution.v2.Action], +// however, the client will need to also upload the +// [Command][build.bazel.remote.execution.v2.Command] and input root +// [Directory][build.bazel.remote.execution.v2.Directory] for the Action. +// The Command and Directory messages must be marshalled to wire format and then +// uploaded under the hash as with any other piece of content. In practice, the +// input root directory is likely to refer to other Directories in its +// hierarchy, which must also each be uploaded on their own. +// +// For small file uploads the client should group them together and call +// [BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +// +// For large uploads, the client must use the +// [Write method][google.bytestream.ByteStream.Write] of the ByteStream API. +// +// For uncompressed data, the `WriteRequest.resource_name` is of the following form: +// `{instance_name}/uploads/{uuid}/blobs/{digest_function/}{hash}/{size}{/optional_metadata}` +// +// Where: +// - `instance_name` is an identifier used to distinguish between the various +// instances on the server. Syntax and semantics of this field are defined +// by the server; Clients must not make any assumptions about it (e.g., +// whether it spans multiple path segments or not). If it is the empty path, +// the leading slash is omitted, so that the `resource_name` becomes +// `uploads/{uuid}/blobs/{digest_function/}{hash}/{size}{/optional_metadata}`. +// To simplify parsing, a path segment cannot equal any of the following +// keywords: `blobs`, `uploads`, `actions`, `actionResults`, `operations`, +// `capabilities` or `compressed-blobs`. +// - `uuid` is a version 4 UUID generated by the client, used to avoid +// collisions between concurrent uploads of the same data. Clients MAY +// reuse the same `uuid` for uploading different blobs. +// - `digest_function` is a lowercase string form of a `DigestFunction.Value` +// enum, indicating which digest function was used to compute `hash`. If the +// digest function used is one of MD5, MURMUR3, SHA1, SHA256, SHA384, SHA512, +// or VSO, this component MUST be omitted. In that case the server SHOULD +// infer the digest function using the length of the `hash` and the digest +// functions announced in the server's capabilities. +// - `hash` and `size` refer to the [Digest][build.bazel.remote.execution.v2.Digest] +// of the data being uploaded. +// - `optional_metadata` is implementation specific data, which clients MAY omit. +// Servers MAY ignore this metadata. +// +// Data can alternatively be uploaded in compressed form, with the following +// `WriteRequest.resource_name` form: +// `{instance_name}/uploads/{uuid}/compressed-blobs/{compressor}/{digest_function/}{uncompressed_hash}/{uncompressed_size}{/optional_metadata}` +// +// Where: +// - `instance_name`, `uuid`, `digest_function` and `optional_metadata` are +// defined as above. +// - `compressor` is a lowercase string form of a `Compressor.Value` enum +// other than `identity`, which is supported by the server and advertised in +// [CacheCapabilities.supported_compressors][build.bazel.remote.execution.v2.CacheCapabilities.supported_compressors]. +// - `uncompressed_hash` and `uncompressed_size` refer to the +// [Digest][build.bazel.remote.execution.v2.Digest] of the data being +// uploaded, once uncompressed. Servers MUST verify that these match +// the uploaded data once uncompressed, and MUST return an +// `INVALID_ARGUMENT` error in the case of mismatch. +// +// Note that when writing compressed blobs, the `WriteRequest.write_offset` in +// the initial request in a stream refers to the offset in the uncompressed form +// of the blob. In subsequent requests, `WriteRequest.write_offset` MUST be the +// sum of the first request's 'WriteRequest.write_offset' and the total size of +// all the compressed data bundles in the previous requests. +// Note that this mixes an uncompressed offset with a compressed byte length, +// which is nonsensical, but it is done to fit the semantics of the existing +// ByteStream protocol. +// +// Uploads of the same data MAY occur concurrently in any form, compressed or +// uncompressed. +// +// Clients SHOULD NOT use gRPC-level compression for ByteStream API `Write` +// calls of compressed blobs, since this would compress already-compressed data. +// +// When attempting an upload, if another client has already completed the upload +// (which may occur in the middle of a single upload if another client uploads +// the same blob concurrently), the request will terminate immediately without +// error, and with a response whose `committed_size` is the value `-1` if this +// is a compressed upload, or with the full size of the uploaded file if this is +// an uncompressed upload (regardless of how much data was transmitted by the +// client). If the client completes the upload but the +// [Digest][build.bazel.remote.execution.v2.Digest] does not match, an +// `INVALID_ARGUMENT` error will be returned. In either case, the client should +// not attempt to retry the upload. +// +// Small downloads can be grouped and requested in a batch via +// [BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. +// +// For large downloads, the client must use the +// [Read method][google.bytestream.ByteStream.Read] of the ByteStream API. +// +// For uncompressed data, the `ReadRequest.resource_name` is of the following form: +// `{instance_name}/blobs/{digest_function/}{hash}/{size}` +// Where `instance_name`, `digest_function`, `hash` and `size` are defined as +// for uploads. +// +// Data can alternatively be downloaded in compressed form, with the following +// `ReadRequest.resource_name` form: +// `{instance_name}/compressed-blobs/{compressor}/{digest_function/}{uncompressed_hash}/{uncompressed_size}` +// +// Where: +// - `instance_name`, `compressor` and `digest_function` are defined as for +// uploads. +// - `uncompressed_hash` and `uncompressed_size` refer to the +// [Digest][build.bazel.remote.execution.v2.Digest] of the data being +// downloaded, once uncompressed. Clients MUST verify that these match +// the downloaded data once uncompressed, and take appropriate steps in +// the case of failure such as retrying a limited number of times or +// surfacing an error to the user. +// +// When downloading compressed blobs: +// - `ReadRequest.read_offset` refers to the offset in the uncompressed form +// of the blob. +// - Servers MUST return `INVALID_ARGUMENT` if `ReadRequest.read_limit` is +// non-zero. +// - Servers MAY use any compression level they choose, including different +// levels for different blobs (e.g. choosing a level designed for maximum +// speed for data known to be incompressible). +// - Clients SHOULD NOT use gRPC-level compression, since this would compress +// already-compressed data. +// +// Servers MUST be able to provide data for all recently advertised blobs in +// each of the compression formats that the server supports, as well as in +// uncompressed form. +// +// Additionally, ByteStream requests MAY come with an additional plain text header +// that indicates the `resource_name` of the blob being sent. The header, if +// present, MUST follow the following convention: +// * name: `build.bazel.remote.execution.v2.resource-name`. +// * contents: the plain text resource_name of the request message. +// If set, the contents of the header MUST match the `resource_name` of the request +// message. Servers MAY use this header to assist in routing requests to the +// appropriate backend. +// +// The lifetime of entries in the CAS is implementation specific, but it SHOULD +// be long enough to allow for newly-added and recently looked-up entries to be +// used in subsequent calls (e.g. to +// [Execute][build.bazel.remote.execution.v2.Execution.Execute]). +// +// Servers MUST behave as though empty blobs are always available, even if they +// have not been uploaded. Clients MAY optimize away the uploading or +// downloading of empty blobs. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +type ContentAddressableStorageClient interface { + // Determine if blobs are present in the CAS. + // + // Clients can use this API before uploading blobs to determine which ones are + // already present in the CAS and do not need to be uploaded again. + // + // Servers SHOULD increase the lifetimes of the referenced blobs if necessary and + // applicable. + // + // There are no method-specific errors. + FindMissingBlobs(ctx context.Context, in *FindMissingBlobsRequest, opts ...grpc.CallOption) (*FindMissingBlobsResponse, error) + // Upload many blobs at once. + // + // The server may enforce a limit of the combined total size of blobs + // to be uploaded using this API. This limit may be obtained using the + // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. + // Requests exceeding the limit should either be split into smaller + // chunks or uploaded using the + // [ByteStream API][google.bytestream.ByteStream], as appropriate. + // + // This request is equivalent to calling a Bytestream `Write` request + // on each individual blob, in parallel. The requests may succeed or fail + // independently. + // + // Errors: + // + // - `INVALID_ARGUMENT`: The client attempted to upload more than the + // server supported limit. + // + // Individual requests may return the following errors, additionally: + // + // * `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob. + // * `INVALID_ARGUMENT`: The + // [Digest][build.bazel.remote.execution.v2.Digest] does not match the + // provided data. + BatchUpdateBlobs(ctx context.Context, in *BatchUpdateBlobsRequest, opts ...grpc.CallOption) (*BatchUpdateBlobsResponse, error) + // Download many blobs at once. + // + // The server may enforce a limit of the combined total size of blobs + // to be downloaded using this API. This limit may be obtained using the + // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. + // Requests exceeding the limit should either be split into smaller + // chunks or downloaded using the + // [ByteStream API][google.bytestream.ByteStream], as appropriate. + // + // This request is equivalent to calling a Bytestream `Read` request + // on each individual blob, in parallel. The requests may succeed or fail + // independently. + // + // Errors: + // + // - `INVALID_ARGUMENT`: The client attempted to read more than the + // server supported limit. + // + // Every error on individual read will be returned in the corresponding digest + // status. + BatchReadBlobs(ctx context.Context, in *BatchReadBlobsRequest, opts ...grpc.CallOption) (*BatchReadBlobsResponse, error) + // Fetch the entire directory tree rooted at a node. + // + // This request must be targeted at a + // [Directory][build.bazel.remote.execution.v2.Directory] stored in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] + // (CAS). The server will enumerate the `Directory` tree recursively and + // return every node descended from the root. + // + // The GetTreeRequest.page_token parameter can be used to skip ahead in + // the stream (e.g. when retrying a partially completed and aborted request), + // by setting it to a value taken from GetTreeResponse.next_page_token of the + // last successfully processed GetTreeResponse). + // + // The exact traversal order is unspecified and, unless retrieving subsequent + // pages from an earlier request, is not guaranteed to be stable across + // multiple invocations of `GetTree`. + // + // If part of the tree is missing from the CAS, the server will return the + // portion present and omit the rest. + // + // Errors: + // + // * `NOT_FOUND`: The requested tree root is not present in the CAS. + GetTree(ctx context.Context, in *GetTreeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GetTreeResponse], error) + // SplitBlob retrieves information about how a blob is split into chunks. + // + // This call returns information about how a blob is split into chunks, and + // returns a list of the chunk digests. Using the returned list of chunk digests, + // a client can check which chunks are locally available and only fetch the + // missing ones. The desired blob can be assembled by concatenating the fetched + // chunks in the order of the digests in the list. The chunks SHOULD all be + // available in the CAS. + // + // This API can be used to reduce the required data to download a large blob + // from CAS if some chunks from similar blobs are locally available. For this + // procedure to work properly, blobs SHOULD be split in a content-defined way, + // rather than with fixed-sized chunking. + // + // If a split request is answered successfully, a client can expect the + // following guarantees from the server: + // 1. The blob chunks are stored in CAS. + // 2. Concatenating the blob chunks in the order of the digest list returned + // by the server results in the original blob. + // + // Servers which implement this functionality MUST declare that they support + // it by setting the + // [CacheCapabilities.split_blob_support][build.bazel.remote.execution.v2.CacheCapabilities.split_blob_support] + // field accordingly. + // + // Clients MUST check that the server supports this capability, before using + // it. + // + // Clients SHOULD verify that the digest of the blob assembled by the fetched + // chunks is equal to the requested blob digest. + // + // The lifetimes of the generated chunk blobs MAY be independent of the + // lifetime of the original blob. In particular: + // - A blob and any chunk derived from it MAY be evicted from the CAS at + // different times. + // - A call to [SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // extends the lifetime of the original blob, and sets the lifetimes of + // the resulting chunks (or extends the lifetimes of already-existing + // chunks). + // - Touching a chunk extends its lifetime, but the server MAY choose not + // to extend the lifetime of the original blob. + // - Touching the original blob extends its lifetime, but the server MAY + // choose not to extend the lifetimes of chunks derived from it. + // + // When blob splitting and splicing is used at the same time, the clients and + // the server SHOULD agree out-of-band upon a chunking algorithm used by both + // parties to benefit from each other's chunk data and avoid unnecessary data + // duplication. + // + // Errors: + // + // - `NOT_FOUND`: The requested blob is not present in the CAS, OR there is no + // split information available for the blob, OR at least one chunk needed to + // reconstruct the blob is missing from the CAS. + // - `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob + // chunks. + SplitBlob(ctx context.Context, in *SplitBlobRequest, opts ...grpc.CallOption) (*SplitBlobResponse, error) + // SpliceBlob tells the CAS how chunks can compose a blob. + // + // This is the complementary operation to the + // [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // function to handle the chunked upload of large blobs to save upload + // traffic. + // + // When uploading a large blob using chunked upload, clients MUST first upload + // all chunks to the CAS, then call this RPC to tell the server how those chunks + // compose the original blob. The chunks referenced in the SpliceBlob call SHOULD be + // available in the CAS before calling this RPC. + // + // If a client needs to upload a large blob and is able to split a blob into + // chunks in such a way that reusable chunks are obtained, e.g., by means of + // content-defined chunking, it can first determine which parts of the blob + // are already available in the remote CAS and upload the missing chunks, and + // then use this API to store information on how the chunks compose the + // original blob. + // + // Servers which implement this functionality MUST declare that they support + // it by setting the + // [CacheCapabilities.splice_blob_support][build.bazel.remote.execution.v2.CacheCapabilities.splice_blob_support] + // field accordingly. + // + // Clients MUST check that the server supports this capability, before using + // it. + // + // In order to ensure data consistency of the CAS, the server MUST only add + // blobs to the CAS after verifying their digests. In particular, servers MUST NOT + // trust digests provided by the client. The server MAY accept a request as no-op + // if the client-specified blob is already in CAS or if information on how to + // construct the blob from chunks is available. If the client-specified blob is + // not already in the CAS, the server MUST verify that the digest of the newly + // created blob assembled from chunks matches the digest specified by the + // client, and reject the request if they differ. Servers MAY choose to allow + // overwriting existing chunk mappings or to store multiple chunk mappings for + // the same blob. + // + // When blob splitting and splicing is used at the same time, the clients and + // the server SHOULD agree out-of-band upon a chunking algorithm used by both + // parties to benefit from each other's chunk data and avoid unnecessary data + // duplication. + // + // Errors: + // + // - `NOT_FOUND`: At least one of the blob chunks is not present in the CAS. + // - `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the + // spliced blob. + // - `INVALID_ARGUMENT`: The digest of the spliced blob is different from the + // provided expected digest. + // - `ALREADY_EXISTS`: The blob already exists in CAS and the server did not + // extend the lifetime of the chunks specified in the request, e.g. because + // it prefers a different chunking and extended those instead. Clients can + // call [SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // to check what chunk mapping the server is using. + SpliceBlob(ctx context.Context, in *SpliceBlobRequest, opts ...grpc.CallOption) (*SpliceBlobResponse, error) +} + +type contentAddressableStorageClient struct { + cc grpc.ClientConnInterface +} + +func NewContentAddressableStorageClient(cc grpc.ClientConnInterface) ContentAddressableStorageClient { + return &contentAddressableStorageClient{cc} +} + +func (c *contentAddressableStorageClient) FindMissingBlobs(ctx context.Context, in *FindMissingBlobsRequest, opts ...grpc.CallOption) (*FindMissingBlobsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(FindMissingBlobsResponse) + err := c.cc.Invoke(ctx, ContentAddressableStorage_FindMissingBlobs_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *contentAddressableStorageClient) BatchUpdateBlobs(ctx context.Context, in *BatchUpdateBlobsRequest, opts ...grpc.CallOption) (*BatchUpdateBlobsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(BatchUpdateBlobsResponse) + err := c.cc.Invoke(ctx, ContentAddressableStorage_BatchUpdateBlobs_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *contentAddressableStorageClient) BatchReadBlobs(ctx context.Context, in *BatchReadBlobsRequest, opts ...grpc.CallOption) (*BatchReadBlobsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(BatchReadBlobsResponse) + err := c.cc.Invoke(ctx, ContentAddressableStorage_BatchReadBlobs_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *contentAddressableStorageClient) GetTree(ctx context.Context, in *GetTreeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GetTreeResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &ContentAddressableStorage_ServiceDesc.Streams[0], ContentAddressableStorage_GetTree_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[GetTreeRequest, GetTreeResponse]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type ContentAddressableStorage_GetTreeClient = grpc.ServerStreamingClient[GetTreeResponse] + +func (c *contentAddressableStorageClient) SplitBlob(ctx context.Context, in *SplitBlobRequest, opts ...grpc.CallOption) (*SplitBlobResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SplitBlobResponse) + err := c.cc.Invoke(ctx, ContentAddressableStorage_SplitBlob_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *contentAddressableStorageClient) SpliceBlob(ctx context.Context, in *SpliceBlobRequest, opts ...grpc.CallOption) (*SpliceBlobResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SpliceBlobResponse) + err := c.cc.Invoke(ctx, ContentAddressableStorage_SpliceBlob_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ContentAddressableStorageServer is the server API for ContentAddressableStorage service. +// All implementations must embed UnimplementedContentAddressableStorageServer +// for forward compatibility. +// +// The CAS (content-addressable storage) is used to store the inputs to and +// outputs from the execution service. Each piece of content is addressed by the +// digest of its binary data. +// +// Most of the binary data stored in the CAS is opaque to the execution engine, +// and is only used as a communication medium. In order to build an +// [Action][build.bazel.remote.execution.v2.Action], +// however, the client will need to also upload the +// [Command][build.bazel.remote.execution.v2.Command] and input root +// [Directory][build.bazel.remote.execution.v2.Directory] for the Action. +// The Command and Directory messages must be marshalled to wire format and then +// uploaded under the hash as with any other piece of content. In practice, the +// input root directory is likely to refer to other Directories in its +// hierarchy, which must also each be uploaded on their own. +// +// For small file uploads the client should group them together and call +// [BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +// +// For large uploads, the client must use the +// [Write method][google.bytestream.ByteStream.Write] of the ByteStream API. +// +// For uncompressed data, the `WriteRequest.resource_name` is of the following form: +// `{instance_name}/uploads/{uuid}/blobs/{digest_function/}{hash}/{size}{/optional_metadata}` +// +// Where: +// - `instance_name` is an identifier used to distinguish between the various +// instances on the server. Syntax and semantics of this field are defined +// by the server; Clients must not make any assumptions about it (e.g., +// whether it spans multiple path segments or not). If it is the empty path, +// the leading slash is omitted, so that the `resource_name` becomes +// `uploads/{uuid}/blobs/{digest_function/}{hash}/{size}{/optional_metadata}`. +// To simplify parsing, a path segment cannot equal any of the following +// keywords: `blobs`, `uploads`, `actions`, `actionResults`, `operations`, +// `capabilities` or `compressed-blobs`. +// - `uuid` is a version 4 UUID generated by the client, used to avoid +// collisions between concurrent uploads of the same data. Clients MAY +// reuse the same `uuid` for uploading different blobs. +// - `digest_function` is a lowercase string form of a `DigestFunction.Value` +// enum, indicating which digest function was used to compute `hash`. If the +// digest function used is one of MD5, MURMUR3, SHA1, SHA256, SHA384, SHA512, +// or VSO, this component MUST be omitted. In that case the server SHOULD +// infer the digest function using the length of the `hash` and the digest +// functions announced in the server's capabilities. +// - `hash` and `size` refer to the [Digest][build.bazel.remote.execution.v2.Digest] +// of the data being uploaded. +// - `optional_metadata` is implementation specific data, which clients MAY omit. +// Servers MAY ignore this metadata. +// +// Data can alternatively be uploaded in compressed form, with the following +// `WriteRequest.resource_name` form: +// `{instance_name}/uploads/{uuid}/compressed-blobs/{compressor}/{digest_function/}{uncompressed_hash}/{uncompressed_size}{/optional_metadata}` +// +// Where: +// - `instance_name`, `uuid`, `digest_function` and `optional_metadata` are +// defined as above. +// - `compressor` is a lowercase string form of a `Compressor.Value` enum +// other than `identity`, which is supported by the server and advertised in +// [CacheCapabilities.supported_compressors][build.bazel.remote.execution.v2.CacheCapabilities.supported_compressors]. +// - `uncompressed_hash` and `uncompressed_size` refer to the +// [Digest][build.bazel.remote.execution.v2.Digest] of the data being +// uploaded, once uncompressed. Servers MUST verify that these match +// the uploaded data once uncompressed, and MUST return an +// `INVALID_ARGUMENT` error in the case of mismatch. +// +// Note that when writing compressed blobs, the `WriteRequest.write_offset` in +// the initial request in a stream refers to the offset in the uncompressed form +// of the blob. In subsequent requests, `WriteRequest.write_offset` MUST be the +// sum of the first request's 'WriteRequest.write_offset' and the total size of +// all the compressed data bundles in the previous requests. +// Note that this mixes an uncompressed offset with a compressed byte length, +// which is nonsensical, but it is done to fit the semantics of the existing +// ByteStream protocol. +// +// Uploads of the same data MAY occur concurrently in any form, compressed or +// uncompressed. +// +// Clients SHOULD NOT use gRPC-level compression for ByteStream API `Write` +// calls of compressed blobs, since this would compress already-compressed data. +// +// When attempting an upload, if another client has already completed the upload +// (which may occur in the middle of a single upload if another client uploads +// the same blob concurrently), the request will terminate immediately without +// error, and with a response whose `committed_size` is the value `-1` if this +// is a compressed upload, or with the full size of the uploaded file if this is +// an uncompressed upload (regardless of how much data was transmitted by the +// client). If the client completes the upload but the +// [Digest][build.bazel.remote.execution.v2.Digest] does not match, an +// `INVALID_ARGUMENT` error will be returned. In either case, the client should +// not attempt to retry the upload. +// +// Small downloads can be grouped and requested in a batch via +// [BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. +// +// For large downloads, the client must use the +// [Read method][google.bytestream.ByteStream.Read] of the ByteStream API. +// +// For uncompressed data, the `ReadRequest.resource_name` is of the following form: +// `{instance_name}/blobs/{digest_function/}{hash}/{size}` +// Where `instance_name`, `digest_function`, `hash` and `size` are defined as +// for uploads. +// +// Data can alternatively be downloaded in compressed form, with the following +// `ReadRequest.resource_name` form: +// `{instance_name}/compressed-blobs/{compressor}/{digest_function/}{uncompressed_hash}/{uncompressed_size}` +// +// Where: +// - `instance_name`, `compressor` and `digest_function` are defined as for +// uploads. +// - `uncompressed_hash` and `uncompressed_size` refer to the +// [Digest][build.bazel.remote.execution.v2.Digest] of the data being +// downloaded, once uncompressed. Clients MUST verify that these match +// the downloaded data once uncompressed, and take appropriate steps in +// the case of failure such as retrying a limited number of times or +// surfacing an error to the user. +// +// When downloading compressed blobs: +// - `ReadRequest.read_offset` refers to the offset in the uncompressed form +// of the blob. +// - Servers MUST return `INVALID_ARGUMENT` if `ReadRequest.read_limit` is +// non-zero. +// - Servers MAY use any compression level they choose, including different +// levels for different blobs (e.g. choosing a level designed for maximum +// speed for data known to be incompressible). +// - Clients SHOULD NOT use gRPC-level compression, since this would compress +// already-compressed data. +// +// Servers MUST be able to provide data for all recently advertised blobs in +// each of the compression formats that the server supports, as well as in +// uncompressed form. +// +// Additionally, ByteStream requests MAY come with an additional plain text header +// that indicates the `resource_name` of the blob being sent. The header, if +// present, MUST follow the following convention: +// * name: `build.bazel.remote.execution.v2.resource-name`. +// * contents: the plain text resource_name of the request message. +// If set, the contents of the header MUST match the `resource_name` of the request +// message. Servers MAY use this header to assist in routing requests to the +// appropriate backend. +// +// The lifetime of entries in the CAS is implementation specific, but it SHOULD +// be long enough to allow for newly-added and recently looked-up entries to be +// used in subsequent calls (e.g. to +// [Execute][build.bazel.remote.execution.v2.Execution.Execute]). +// +// Servers MUST behave as though empty blobs are always available, even if they +// have not been uploaded. Clients MAY optimize away the uploading or +// downloading of empty blobs. +// +// As with other services in the Remote Execution API, any call may return an +// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +// information about when the client should retry the request; clients SHOULD +// respect the information provided. +type ContentAddressableStorageServer interface { + // Determine if blobs are present in the CAS. + // + // Clients can use this API before uploading blobs to determine which ones are + // already present in the CAS and do not need to be uploaded again. + // + // Servers SHOULD increase the lifetimes of the referenced blobs if necessary and + // applicable. + // + // There are no method-specific errors. + FindMissingBlobs(context.Context, *FindMissingBlobsRequest) (*FindMissingBlobsResponse, error) + // Upload many blobs at once. + // + // The server may enforce a limit of the combined total size of blobs + // to be uploaded using this API. This limit may be obtained using the + // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. + // Requests exceeding the limit should either be split into smaller + // chunks or uploaded using the + // [ByteStream API][google.bytestream.ByteStream], as appropriate. + // + // This request is equivalent to calling a Bytestream `Write` request + // on each individual blob, in parallel. The requests may succeed or fail + // independently. + // + // Errors: + // + // - `INVALID_ARGUMENT`: The client attempted to upload more than the + // server supported limit. + // + // Individual requests may return the following errors, additionally: + // + // * `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob. + // * `INVALID_ARGUMENT`: The + // [Digest][build.bazel.remote.execution.v2.Digest] does not match the + // provided data. + BatchUpdateBlobs(context.Context, *BatchUpdateBlobsRequest) (*BatchUpdateBlobsResponse, error) + // Download many blobs at once. + // + // The server may enforce a limit of the combined total size of blobs + // to be downloaded using this API. This limit may be obtained using the + // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. + // Requests exceeding the limit should either be split into smaller + // chunks or downloaded using the + // [ByteStream API][google.bytestream.ByteStream], as appropriate. + // + // This request is equivalent to calling a Bytestream `Read` request + // on each individual blob, in parallel. The requests may succeed or fail + // independently. + // + // Errors: + // + // - `INVALID_ARGUMENT`: The client attempted to read more than the + // server supported limit. + // + // Every error on individual read will be returned in the corresponding digest + // status. + BatchReadBlobs(context.Context, *BatchReadBlobsRequest) (*BatchReadBlobsResponse, error) + // Fetch the entire directory tree rooted at a node. + // + // This request must be targeted at a + // [Directory][build.bazel.remote.execution.v2.Directory] stored in the + // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] + // (CAS). The server will enumerate the `Directory` tree recursively and + // return every node descended from the root. + // + // The GetTreeRequest.page_token parameter can be used to skip ahead in + // the stream (e.g. when retrying a partially completed and aborted request), + // by setting it to a value taken from GetTreeResponse.next_page_token of the + // last successfully processed GetTreeResponse). + // + // The exact traversal order is unspecified and, unless retrieving subsequent + // pages from an earlier request, is not guaranteed to be stable across + // multiple invocations of `GetTree`. + // + // If part of the tree is missing from the CAS, the server will return the + // portion present and omit the rest. + // + // Errors: + // + // * `NOT_FOUND`: The requested tree root is not present in the CAS. + GetTree(*GetTreeRequest, grpc.ServerStreamingServer[GetTreeResponse]) error + // SplitBlob retrieves information about how a blob is split into chunks. + // + // This call returns information about how a blob is split into chunks, and + // returns a list of the chunk digests. Using the returned list of chunk digests, + // a client can check which chunks are locally available and only fetch the + // missing ones. The desired blob can be assembled by concatenating the fetched + // chunks in the order of the digests in the list. The chunks SHOULD all be + // available in the CAS. + // + // This API can be used to reduce the required data to download a large blob + // from CAS if some chunks from similar blobs are locally available. For this + // procedure to work properly, blobs SHOULD be split in a content-defined way, + // rather than with fixed-sized chunking. + // + // If a split request is answered successfully, a client can expect the + // following guarantees from the server: + // 1. The blob chunks are stored in CAS. + // 2. Concatenating the blob chunks in the order of the digest list returned + // by the server results in the original blob. + // + // Servers which implement this functionality MUST declare that they support + // it by setting the + // [CacheCapabilities.split_blob_support][build.bazel.remote.execution.v2.CacheCapabilities.split_blob_support] + // field accordingly. + // + // Clients MUST check that the server supports this capability, before using + // it. + // + // Clients SHOULD verify that the digest of the blob assembled by the fetched + // chunks is equal to the requested blob digest. + // + // The lifetimes of the generated chunk blobs MAY be independent of the + // lifetime of the original blob. In particular: + // - A blob and any chunk derived from it MAY be evicted from the CAS at + // different times. + // - A call to [SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // extends the lifetime of the original blob, and sets the lifetimes of + // the resulting chunks (or extends the lifetimes of already-existing + // chunks). + // - Touching a chunk extends its lifetime, but the server MAY choose not + // to extend the lifetime of the original blob. + // - Touching the original blob extends its lifetime, but the server MAY + // choose not to extend the lifetimes of chunks derived from it. + // + // When blob splitting and splicing is used at the same time, the clients and + // the server SHOULD agree out-of-band upon a chunking algorithm used by both + // parties to benefit from each other's chunk data and avoid unnecessary data + // duplication. + // + // Errors: + // + // - `NOT_FOUND`: The requested blob is not present in the CAS, OR there is no + // split information available for the blob, OR at least one chunk needed to + // reconstruct the blob is missing from the CAS. + // - `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob + // chunks. + SplitBlob(context.Context, *SplitBlobRequest) (*SplitBlobResponse, error) + // SpliceBlob tells the CAS how chunks can compose a blob. + // + // This is the complementary operation to the + // [ContentAddressableStorage.SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // function to handle the chunked upload of large blobs to save upload + // traffic. + // + // When uploading a large blob using chunked upload, clients MUST first upload + // all chunks to the CAS, then call this RPC to tell the server how those chunks + // compose the original blob. The chunks referenced in the SpliceBlob call SHOULD be + // available in the CAS before calling this RPC. + // + // If a client needs to upload a large blob and is able to split a blob into + // chunks in such a way that reusable chunks are obtained, e.g., by means of + // content-defined chunking, it can first determine which parts of the blob + // are already available in the remote CAS and upload the missing chunks, and + // then use this API to store information on how the chunks compose the + // original blob. + // + // Servers which implement this functionality MUST declare that they support + // it by setting the + // [CacheCapabilities.splice_blob_support][build.bazel.remote.execution.v2.CacheCapabilities.splice_blob_support] + // field accordingly. + // + // Clients MUST check that the server supports this capability, before using + // it. + // + // In order to ensure data consistency of the CAS, the server MUST only add + // blobs to the CAS after verifying their digests. In particular, servers MUST NOT + // trust digests provided by the client. The server MAY accept a request as no-op + // if the client-specified blob is already in CAS or if information on how to + // construct the blob from chunks is available. If the client-specified blob is + // not already in the CAS, the server MUST verify that the digest of the newly + // created blob assembled from chunks matches the digest specified by the + // client, and reject the request if they differ. Servers MAY choose to allow + // overwriting existing chunk mappings or to store multiple chunk mappings for + // the same blob. + // + // When blob splitting and splicing is used at the same time, the clients and + // the server SHOULD agree out-of-band upon a chunking algorithm used by both + // parties to benefit from each other's chunk data and avoid unnecessary data + // duplication. + // + // Errors: + // + // - `NOT_FOUND`: At least one of the blob chunks is not present in the CAS. + // - `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the + // spliced blob. + // - `INVALID_ARGUMENT`: The digest of the spliced blob is different from the + // provided expected digest. + // - `ALREADY_EXISTS`: The blob already exists in CAS and the server did not + // extend the lifetime of the chunks specified in the request, e.g. because + // it prefers a different chunking and extended those instead. Clients can + // call [SplitBlob][build.bazel.remote.execution.v2.ContentAddressableStorage.SplitBlob] + // to check what chunk mapping the server is using. + SpliceBlob(context.Context, *SpliceBlobRequest) (*SpliceBlobResponse, error) + mustEmbedUnimplementedContentAddressableStorageServer() +} + +// UnimplementedContentAddressableStorageServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedContentAddressableStorageServer struct{} + +func (UnimplementedContentAddressableStorageServer) FindMissingBlobs(context.Context, *FindMissingBlobsRequest) (*FindMissingBlobsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindMissingBlobs not implemented") +} +func (UnimplementedContentAddressableStorageServer) BatchUpdateBlobs(context.Context, *BatchUpdateBlobsRequest) (*BatchUpdateBlobsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BatchUpdateBlobs not implemented") +} +func (UnimplementedContentAddressableStorageServer) BatchReadBlobs(context.Context, *BatchReadBlobsRequest) (*BatchReadBlobsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BatchReadBlobs not implemented") +} +func (UnimplementedContentAddressableStorageServer) GetTree(*GetTreeRequest, grpc.ServerStreamingServer[GetTreeResponse]) error { + return status.Errorf(codes.Unimplemented, "method GetTree not implemented") +} +func (UnimplementedContentAddressableStorageServer) SplitBlob(context.Context, *SplitBlobRequest) (*SplitBlobResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SplitBlob not implemented") +} +func (UnimplementedContentAddressableStorageServer) SpliceBlob(context.Context, *SpliceBlobRequest) (*SpliceBlobResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SpliceBlob not implemented") +} +func (UnimplementedContentAddressableStorageServer) mustEmbedUnimplementedContentAddressableStorageServer() { +} +func (UnimplementedContentAddressableStorageServer) testEmbeddedByValue() {} + +// UnsafeContentAddressableStorageServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ContentAddressableStorageServer will +// result in compilation errors. +type UnsafeContentAddressableStorageServer interface { + mustEmbedUnimplementedContentAddressableStorageServer() +} + +func RegisterContentAddressableStorageServer(s grpc.ServiceRegistrar, srv ContentAddressableStorageServer) { + // If the following call pancis, it indicates UnimplementedContentAddressableStorageServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ContentAddressableStorage_ServiceDesc, srv) +} + +func _ContentAddressableStorage_FindMissingBlobs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FindMissingBlobsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContentAddressableStorageServer).FindMissingBlobs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ContentAddressableStorage_FindMissingBlobs_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentAddressableStorageServer).FindMissingBlobs(ctx, req.(*FindMissingBlobsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ContentAddressableStorage_BatchUpdateBlobs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BatchUpdateBlobsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContentAddressableStorageServer).BatchUpdateBlobs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ContentAddressableStorage_BatchUpdateBlobs_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentAddressableStorageServer).BatchUpdateBlobs(ctx, req.(*BatchUpdateBlobsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ContentAddressableStorage_BatchReadBlobs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BatchReadBlobsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContentAddressableStorageServer).BatchReadBlobs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ContentAddressableStorage_BatchReadBlobs_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentAddressableStorageServer).BatchReadBlobs(ctx, req.(*BatchReadBlobsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ContentAddressableStorage_GetTree_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetTreeRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ContentAddressableStorageServer).GetTree(m, &grpc.GenericServerStream[GetTreeRequest, GetTreeResponse]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type ContentAddressableStorage_GetTreeServer = grpc.ServerStreamingServer[GetTreeResponse] + +func _ContentAddressableStorage_SplitBlob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SplitBlobRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContentAddressableStorageServer).SplitBlob(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ContentAddressableStorage_SplitBlob_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentAddressableStorageServer).SplitBlob(ctx, req.(*SplitBlobRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ContentAddressableStorage_SpliceBlob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SpliceBlobRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContentAddressableStorageServer).SpliceBlob(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ContentAddressableStorage_SpliceBlob_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentAddressableStorageServer).SpliceBlob(ctx, req.(*SpliceBlobRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ContentAddressableStorage_ServiceDesc is the grpc.ServiceDesc for ContentAddressableStorage service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ContentAddressableStorage_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "build.bazel.remote.execution.v2.ContentAddressableStorage", + HandlerType: (*ContentAddressableStorageServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "FindMissingBlobs", + Handler: _ContentAddressableStorage_FindMissingBlobs_Handler, + }, + { + MethodName: "BatchUpdateBlobs", + Handler: _ContentAddressableStorage_BatchUpdateBlobs_Handler, + }, + { + MethodName: "BatchReadBlobs", + Handler: _ContentAddressableStorage_BatchReadBlobs_Handler, + }, + { + MethodName: "SplitBlob", + Handler: _ContentAddressableStorage_SplitBlob_Handler, + }, + { + MethodName: "SpliceBlob", + Handler: _ContentAddressableStorage_SpliceBlob_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetTree", + Handler: _ContentAddressableStorage_GetTree_Handler, + ServerStreams: true, + }, + }, + Metadata: "build/bazel/remote/execution/v2/remote_execution.proto", +} + +const ( + Capabilities_GetCapabilities_FullMethodName = "/build.bazel.remote.execution.v2.Capabilities/GetCapabilities" +) + +// CapabilitiesClient is the client API for Capabilities service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The Capabilities service may be used by remote execution clients to query +// various server properties, in order to self-configure or return meaningful +// error messages. +// +// The query may include a particular `instance_name`, in which case the values +// returned will pertain to that instance. +type CapabilitiesClient interface { + // GetCapabilities returns the server capabilities configuration of the + // remote endpoint. + // Only the capabilities of the services supported by the endpoint will + // be returned: + // - Execution + CAS + Action Cache endpoints should return both + // CacheCapabilities and ExecutionCapabilities. + // - Execution only endpoints should return ExecutionCapabilities. + // - CAS + Action Cache only endpoints should return CacheCapabilities. + // + // There are no method-specific errors. + GetCapabilities(ctx context.Context, in *GetCapabilitiesRequest, opts ...grpc.CallOption) (*ServerCapabilities, error) +} + +type capabilitiesClient struct { + cc grpc.ClientConnInterface +} + +func NewCapabilitiesClient(cc grpc.ClientConnInterface) CapabilitiesClient { + return &capabilitiesClient{cc} +} + +func (c *capabilitiesClient) GetCapabilities(ctx context.Context, in *GetCapabilitiesRequest, opts ...grpc.CallOption) (*ServerCapabilities, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ServerCapabilities) + err := c.cc.Invoke(ctx, Capabilities_GetCapabilities_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// CapabilitiesServer is the server API for Capabilities service. +// All implementations must embed UnimplementedCapabilitiesServer +// for forward compatibility. +// +// The Capabilities service may be used by remote execution clients to query +// various server properties, in order to self-configure or return meaningful +// error messages. +// +// The query may include a particular `instance_name`, in which case the values +// returned will pertain to that instance. +type CapabilitiesServer interface { + // GetCapabilities returns the server capabilities configuration of the + // remote endpoint. + // Only the capabilities of the services supported by the endpoint will + // be returned: + // - Execution + CAS + Action Cache endpoints should return both + // CacheCapabilities and ExecutionCapabilities. + // - Execution only endpoints should return ExecutionCapabilities. + // - CAS + Action Cache only endpoints should return CacheCapabilities. + // + // There are no method-specific errors. + GetCapabilities(context.Context, *GetCapabilitiesRequest) (*ServerCapabilities, error) + mustEmbedUnimplementedCapabilitiesServer() +} + +// UnimplementedCapabilitiesServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedCapabilitiesServer struct{} + +func (UnimplementedCapabilitiesServer) GetCapabilities(context.Context, *GetCapabilitiesRequest) (*ServerCapabilities, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCapabilities not implemented") +} +func (UnimplementedCapabilitiesServer) mustEmbedUnimplementedCapabilitiesServer() {} +func (UnimplementedCapabilitiesServer) testEmbeddedByValue() {} + +// UnsafeCapabilitiesServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CapabilitiesServer will +// result in compilation errors. +type UnsafeCapabilitiesServer interface { + mustEmbedUnimplementedCapabilitiesServer() +} + +func RegisterCapabilitiesServer(s grpc.ServiceRegistrar, srv CapabilitiesServer) { + // If the following call pancis, it indicates UnimplementedCapabilitiesServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Capabilities_ServiceDesc, srv) +} + +func _Capabilities_GetCapabilities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCapabilitiesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CapabilitiesServer).GetCapabilities(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Capabilities_GetCapabilities_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CapabilitiesServer).GetCapabilities(ctx, req.(*GetCapabilitiesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Capabilities_ServiceDesc is the grpc.ServiceDesc for Capabilities service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Capabilities_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "build.bazel.remote.execution.v2.Capabilities", + HandlerType: (*CapabilitiesServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetCapabilities", + Handler: _Capabilities_GetCapabilities_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "build/bazel/remote/execution/v2/remote_execution.proto", +} diff --git a/internal/proto/gen/build/bazel/semver/semver.pb.go b/internal/proto/gen/build/bazel/semver/semver.pb.go index 94faa99..26f874c 100644 --- a/internal/proto/gen/build/bazel/semver/semver.pb.go +++ b/internal/proto/gen/build/bazel/semver/semver.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 +// protoc-gen-go v1.36.12 // protoc (unknown) // source: build/bazel/semver/semver.proto diff --git a/internal/proto/gen/google/bytestream/bytestream.pb.go b/internal/proto/gen/google/bytestream/bytestream.pb.go new file mode 100644 index 0000000..d374d3b --- /dev/null +++ b/internal/proto/gen/google/bytestream/bytestream.pb.go @@ -0,0 +1,598 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.12 +// protoc (unknown) +// source: google/bytestream/bytestream.proto + +package bytestream + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Request object for ByteStream.Read. +type ReadRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3"` + xxx_hidden_ReadOffset int64 `protobuf:"varint,2,opt,name=read_offset,json=readOffset,proto3"` + xxx_hidden_ReadLimit int64 `protobuf:"varint,3,opt,name=read_limit,json=readLimit,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReadRequest) Reset() { + *x = ReadRequest{} + mi := &file_google_bytestream_bytestream_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadRequest) ProtoMessage() {} + +func (x *ReadRequest) ProtoReflect() protoreflect.Message { + mi := &file_google_bytestream_bytestream_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ReadRequest) GetResourceName() string { + if x != nil { + return x.xxx_hidden_ResourceName + } + return "" +} + +func (x *ReadRequest) GetReadOffset() int64 { + if x != nil { + return x.xxx_hidden_ReadOffset + } + return 0 +} + +func (x *ReadRequest) GetReadLimit() int64 { + if x != nil { + return x.xxx_hidden_ReadLimit + } + return 0 +} + +func (x *ReadRequest) SetResourceName(v string) { + x.xxx_hidden_ResourceName = v +} + +func (x *ReadRequest) SetReadOffset(v int64) { + x.xxx_hidden_ReadOffset = v +} + +func (x *ReadRequest) SetReadLimit(v int64) { + x.xxx_hidden_ReadLimit = v +} + +type ReadRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the resource to read. + ResourceName string + // The offset for the first byte to return in the read, relative to the start + // of the resource. + // + // A `read_offset` that is negative or greater than the size of the resource + // will cause an `OUT_OF_RANGE` error. + ReadOffset int64 + // The maximum number of `data` bytes the server is allowed to return in the + // sum of all `ReadResponse` messages. A `read_limit` of zero indicates that + // there is no limit, and a negative `read_limit` will cause an error. + // + // If the stream returns fewer bytes than allowed by the `read_limit` and no + // error occurred, the stream includes all data from the `read_offset` to the + // end of the resource. + ReadLimit int64 +} + +func (b0 ReadRequest_builder) Build() *ReadRequest { + m0 := &ReadRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_ResourceName = b.ResourceName + x.xxx_hidden_ReadOffset = b.ReadOffset + x.xxx_hidden_ReadLimit = b.ReadLimit + return m0 +} + +// Response object for ByteStream.Read. +type ReadResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Data []byte `protobuf:"bytes,10,opt,name=data,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReadResponse) Reset() { + *x = ReadResponse{} + mi := &file_google_bytestream_bytestream_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadResponse) ProtoMessage() {} + +func (x *ReadResponse) ProtoReflect() protoreflect.Message { + mi := &file_google_bytestream_bytestream_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ReadResponse) GetData() []byte { + if x != nil { + return x.xxx_hidden_Data + } + return nil +} + +func (x *ReadResponse) SetData(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_Data = v +} + +type ReadResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // A portion of the data for the resource. The service **may** leave `data` + // empty for any given `ReadResponse`. This enables the service to inform the + // client that the request is still live while it is running an operation to + // generate more data. + Data []byte +} + +func (b0 ReadResponse_builder) Build() *ReadResponse { + m0 := &ReadResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Data = b.Data + return m0 +} + +// Request object for ByteStream.Write. +type WriteRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3"` + xxx_hidden_WriteOffset int64 `protobuf:"varint,2,opt,name=write_offset,json=writeOffset,proto3"` + xxx_hidden_FinishWrite bool `protobuf:"varint,3,opt,name=finish_write,json=finishWrite,proto3"` + xxx_hidden_Data []byte `protobuf:"bytes,10,opt,name=data,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WriteRequest) Reset() { + *x = WriteRequest{} + mi := &file_google_bytestream_bytestream_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WriteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteRequest) ProtoMessage() {} + +func (x *WriteRequest) ProtoReflect() protoreflect.Message { + mi := &file_google_bytestream_bytestream_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *WriteRequest) GetResourceName() string { + if x != nil { + return x.xxx_hidden_ResourceName + } + return "" +} + +func (x *WriteRequest) GetWriteOffset() int64 { + if x != nil { + return x.xxx_hidden_WriteOffset + } + return 0 +} + +func (x *WriteRequest) GetFinishWrite() bool { + if x != nil { + return x.xxx_hidden_FinishWrite + } + return false +} + +func (x *WriteRequest) GetData() []byte { + if x != nil { + return x.xxx_hidden_Data + } + return nil +} + +func (x *WriteRequest) SetResourceName(v string) { + x.xxx_hidden_ResourceName = v +} + +func (x *WriteRequest) SetWriteOffset(v int64) { + x.xxx_hidden_WriteOffset = v +} + +func (x *WriteRequest) SetFinishWrite(v bool) { + x.xxx_hidden_FinishWrite = v +} + +func (x *WriteRequest) SetData(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_Data = v +} + +type WriteRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the resource to write. This **must** be set on the first + // `WriteRequest` of each `Write()` action. If it is set on subsequent calls, + // it **must** match the value of the first request. + ResourceName string + // The offset from the beginning of the resource at which the data should be + // written. It is required on all `WriteRequest`s. + // + // In the first `WriteRequest` of a `Write()` action, it indicates + // the initial offset for the `Write()` call. The value **must** be equal to + // the `committed_size` that a call to `QueryWriteStatus()` would return. + // + // On subsequent calls, this value **must** be set and **must** be equal to + // the sum of the first `write_offset` and the sizes of all `data` bundles + // sent previously on this stream. + // + // An incorrect value will cause an error. + WriteOffset int64 + // If `true`, this indicates that the write is complete. Sending any + // `WriteRequest`s subsequent to one in which `finish_write` is `true` will + // cause an error. + FinishWrite bool + // A portion of the data for the resource. The client **may** leave `data` + // empty for any given `WriteRequest`. This enables the client to inform the + // service that the request is still live while it is running an operation to + // generate more data. + Data []byte +} + +func (b0 WriteRequest_builder) Build() *WriteRequest { + m0 := &WriteRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_ResourceName = b.ResourceName + x.xxx_hidden_WriteOffset = b.WriteOffset + x.xxx_hidden_FinishWrite = b.FinishWrite + x.xxx_hidden_Data = b.Data + return m0 +} + +// Response object for ByteStream.Write. +type WriteResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_CommittedSize int64 `protobuf:"varint,1,opt,name=committed_size,json=committedSize,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WriteResponse) Reset() { + *x = WriteResponse{} + mi := &file_google_bytestream_bytestream_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WriteResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteResponse) ProtoMessage() {} + +func (x *WriteResponse) ProtoReflect() protoreflect.Message { + mi := &file_google_bytestream_bytestream_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *WriteResponse) GetCommittedSize() int64 { + if x != nil { + return x.xxx_hidden_CommittedSize + } + return 0 +} + +func (x *WriteResponse) SetCommittedSize(v int64) { + x.xxx_hidden_CommittedSize = v +} + +type WriteResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The number of bytes that have been processed for the given resource. + CommittedSize int64 +} + +func (b0 WriteResponse_builder) Build() *WriteResponse { + m0 := &WriteResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_CommittedSize = b.CommittedSize + return m0 +} + +// Request object for ByteStream.QueryWriteStatus. +type QueryWriteStatusRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *QueryWriteStatusRequest) Reset() { + *x = QueryWriteStatusRequest{} + mi := &file_google_bytestream_bytestream_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *QueryWriteStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryWriteStatusRequest) ProtoMessage() {} + +func (x *QueryWriteStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_google_bytestream_bytestream_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *QueryWriteStatusRequest) GetResourceName() string { + if x != nil { + return x.xxx_hidden_ResourceName + } + return "" +} + +func (x *QueryWriteStatusRequest) SetResourceName(v string) { + x.xxx_hidden_ResourceName = v +} + +type QueryWriteStatusRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The name of the resource whose write status is being requested. + ResourceName string +} + +func (b0 QueryWriteStatusRequest_builder) Build() *QueryWriteStatusRequest { + m0 := &QueryWriteStatusRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_ResourceName = b.ResourceName + return m0 +} + +// Response object for ByteStream.QueryWriteStatus. +type QueryWriteStatusResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_CommittedSize int64 `protobuf:"varint,1,opt,name=committed_size,json=committedSize,proto3"` + xxx_hidden_Complete bool `protobuf:"varint,2,opt,name=complete,proto3"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *QueryWriteStatusResponse) Reset() { + *x = QueryWriteStatusResponse{} + mi := &file_google_bytestream_bytestream_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *QueryWriteStatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryWriteStatusResponse) ProtoMessage() {} + +func (x *QueryWriteStatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_google_bytestream_bytestream_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *QueryWriteStatusResponse) GetCommittedSize() int64 { + if x != nil { + return x.xxx_hidden_CommittedSize + } + return 0 +} + +func (x *QueryWriteStatusResponse) GetComplete() bool { + if x != nil { + return x.xxx_hidden_Complete + } + return false +} + +func (x *QueryWriteStatusResponse) SetCommittedSize(v int64) { + x.xxx_hidden_CommittedSize = v +} + +func (x *QueryWriteStatusResponse) SetComplete(v bool) { + x.xxx_hidden_Complete = v +} + +type QueryWriteStatusResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The number of bytes that have been processed for the given resource. + CommittedSize int64 + // `complete` is `true` only if the client has sent a `WriteRequest` with + // `finish_write` set to true, and the server has processed that request. + Complete bool +} + +func (b0 QueryWriteStatusResponse_builder) Build() *QueryWriteStatusResponse { + m0 := &QueryWriteStatusResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_CommittedSize = b.CommittedSize + x.xxx_hidden_Complete = b.Complete + return m0 +} + +var File_google_bytestream_bytestream_proto protoreflect.FileDescriptor + +const file_google_bytestream_bytestream_proto_rawDesc = "" + + "\n" + + "\"google/bytestream/bytestream.proto\x12\x11google.bytestream\"r\n" + + "\vReadRequest\x12#\n" + + "\rresource_name\x18\x01 \x01(\tR\fresourceName\x12\x1f\n" + + "\vread_offset\x18\x02 \x01(\x03R\n" + + "readOffset\x12\x1d\n" + + "\n" + + "read_limit\x18\x03 \x01(\x03R\treadLimit\"\"\n" + + "\fReadResponse\x12\x12\n" + + "\x04data\x18\n" + + " \x01(\fR\x04data\"\x8d\x01\n" + + "\fWriteRequest\x12#\n" + + "\rresource_name\x18\x01 \x01(\tR\fresourceName\x12!\n" + + "\fwrite_offset\x18\x02 \x01(\x03R\vwriteOffset\x12!\n" + + "\ffinish_write\x18\x03 \x01(\bR\vfinishWrite\x12\x12\n" + + "\x04data\x18\n" + + " \x01(\fR\x04data\"6\n" + + "\rWriteResponse\x12%\n" + + "\x0ecommitted_size\x18\x01 \x01(\x03R\rcommittedSize\">\n" + + "\x17QueryWriteStatusRequest\x12#\n" + + "\rresource_name\x18\x01 \x01(\tR\fresourceName\"]\n" + + "\x18QueryWriteStatusResponse\x12%\n" + + "\x0ecommitted_size\x18\x01 \x01(\x03R\rcommittedSize\x12\x1a\n" + + "\bcomplete\x18\x02 \x01(\bR\bcomplete2\x92\x02\n" + + "\n" + + "ByteStream\x12I\n" + + "\x04Read\x12\x1e.google.bytestream.ReadRequest\x1a\x1f.google.bytestream.ReadResponse0\x01\x12L\n" + + "\x05Write\x12\x1f.google.bytestream.WriteRequest\x1a .google.bytestream.WriteResponse(\x01\x12k\n" + + "\x10QueryWriteStatus\x12*.google.bytestream.QueryWriteStatusRequest\x1a+.google.bytestream.QueryWriteStatusResponseBe\n" + + "\x15com.google.bytestreamB\x0fByteStreamProtoZ;google.golang.org/genproto/googleapis/bytestream;bytestreamb\x06proto3" + +var file_google_bytestream_bytestream_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_google_bytestream_bytestream_proto_goTypes = []any{ + (*ReadRequest)(nil), // 0: google.bytestream.ReadRequest + (*ReadResponse)(nil), // 1: google.bytestream.ReadResponse + (*WriteRequest)(nil), // 2: google.bytestream.WriteRequest + (*WriteResponse)(nil), // 3: google.bytestream.WriteResponse + (*QueryWriteStatusRequest)(nil), // 4: google.bytestream.QueryWriteStatusRequest + (*QueryWriteStatusResponse)(nil), // 5: google.bytestream.QueryWriteStatusResponse +} +var file_google_bytestream_bytestream_proto_depIdxs = []int32{ + 0, // 0: google.bytestream.ByteStream.Read:input_type -> google.bytestream.ReadRequest + 2, // 1: google.bytestream.ByteStream.Write:input_type -> google.bytestream.WriteRequest + 4, // 2: google.bytestream.ByteStream.QueryWriteStatus:input_type -> google.bytestream.QueryWriteStatusRequest + 1, // 3: google.bytestream.ByteStream.Read:output_type -> google.bytestream.ReadResponse + 3, // 4: google.bytestream.ByteStream.Write:output_type -> google.bytestream.WriteResponse + 5, // 5: google.bytestream.ByteStream.QueryWriteStatus:output_type -> google.bytestream.QueryWriteStatusResponse + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_google_bytestream_bytestream_proto_init() } +func file_google_bytestream_bytestream_proto_init() { + if File_google_bytestream_bytestream_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_bytestream_bytestream_proto_rawDesc), len(file_google_bytestream_bytestream_proto_rawDesc)), + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_google_bytestream_bytestream_proto_goTypes, + DependencyIndexes: file_google_bytestream_bytestream_proto_depIdxs, + MessageInfos: file_google_bytestream_bytestream_proto_msgTypes, + }.Build() + File_google_bytestream_bytestream_proto = out.File + file_google_bytestream_bytestream_proto_goTypes = nil + file_google_bytestream_bytestream_proto_depIdxs = nil +} diff --git a/internal/proto/gen/google/bytestream/bytestream_grpc.pb.go b/internal/proto/gen/google/bytestream/bytestream_grpc.pb.go new file mode 100644 index 0000000..e7eadd9 --- /dev/null +++ b/internal/proto/gen/google/bytestream/bytestream_grpc.pb.go @@ -0,0 +1,334 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: google/bytestream/bytestream.proto + +package bytestream + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + ByteStream_Read_FullMethodName = "/google.bytestream.ByteStream/Read" + ByteStream_Write_FullMethodName = "/google.bytestream.ByteStream/Write" + ByteStream_QueryWriteStatus_FullMethodName = "/google.bytestream.ByteStream/QueryWriteStatus" +) + +// ByteStreamClient is the client API for ByteStream service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// #### Introduction +// +// The Byte Stream API enables a client to read and write a stream of bytes to +// and from a resource. Resources have names, and these names are supplied in +// the API calls below to identify the resource that is being read from or +// written to. +// +// All implementations of the Byte Stream API export the interface defined here: +// +// * `Read()`: Reads the contents of a resource. +// +// - `Write()`: Writes the contents of a resource. The client can call `Write()` +// multiple times with the same resource and can check the status of the write +// by calling `QueryWriteStatus()`. +// +// #### Service parameters and metadata +// +// The ByteStream API provides no direct way to access/modify any metadata +// associated with the resource. +// +// #### Errors +// +// The errors returned by the service are in the Google canonical error space. +type ByteStreamClient interface { + // `Read()` is used to retrieve the contents of a resource as a sequence + // of bytes. The bytes are returned in a sequence of responses, and the + // responses are delivered as the results of a server-side streaming RPC. + Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadResponse], error) + // `Write()` is used to send the contents of a resource as a sequence of + // bytes. The bytes are sent in a sequence of request protos of a client-side + // streaming RPC. + // + // A `Write()` action is resumable. If there is an error or the connection is + // broken during the `Write()`, the client should check the status of the + // `Write()` by calling `QueryWriteStatus()` and continue writing from the + // returned `committed_size`. This may be less than the amount of data the + // client previously sent. + // + // Calling `Write()` on a resource name that was previously written and + // finalized could cause an error, depending on whether the underlying service + // allows over-writing of previously written resources. + // + // When the client closes the request channel, the service will respond with + // a `WriteResponse`. The service will not view the resource as `complete` + // until the client has sent a `WriteRequest` with `finish_write` set to + // `true`. Sending any requests on a stream after sending a request with + // `finish_write` set to `true` will cause an error. The client **should** + // check the `WriteResponse` it receives to determine how much data the + // service was able to commit and whether the service views the resource as + // `complete` or not. + Write(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[WriteRequest, WriteResponse], error) + // `QueryWriteStatus()` is used to find the `committed_size` for a resource + // that is being written, which can then be used as the `write_offset` for + // the next `Write()` call. + // + // If the resource does not exist (i.e., the resource has been deleted, or the + // first `Write()` has not yet reached the service), this method returns the + // error `NOT_FOUND`. + // + // The client **may** call `QueryWriteStatus()` at any time to determine how + // much data has been processed for this resource. This is useful if the + // client is buffering data and needs to know which data can be safely + // evicted. For any sequence of `QueryWriteStatus()` calls for a given + // resource name, the sequence of returned `committed_size` values will be + // non-decreasing. + QueryWriteStatus(ctx context.Context, in *QueryWriteStatusRequest, opts ...grpc.CallOption) (*QueryWriteStatusResponse, error) +} + +type byteStreamClient struct { + cc grpc.ClientConnInterface +} + +func NewByteStreamClient(cc grpc.ClientConnInterface) ByteStreamClient { + return &byteStreamClient{cc} +} + +func (c *byteStreamClient) Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &ByteStream_ServiceDesc.Streams[0], ByteStream_Read_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[ReadRequest, ReadResponse]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type ByteStream_ReadClient = grpc.ServerStreamingClient[ReadResponse] + +func (c *byteStreamClient) Write(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[WriteRequest, WriteResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &ByteStream_ServiceDesc.Streams[1], ByteStream_Write_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[WriteRequest, WriteResponse]{ClientStream: stream} + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type ByteStream_WriteClient = grpc.ClientStreamingClient[WriteRequest, WriteResponse] + +func (c *byteStreamClient) QueryWriteStatus(ctx context.Context, in *QueryWriteStatusRequest, opts ...grpc.CallOption) (*QueryWriteStatusResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(QueryWriteStatusResponse) + err := c.cc.Invoke(ctx, ByteStream_QueryWriteStatus_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ByteStreamServer is the server API for ByteStream service. +// All implementations must embed UnimplementedByteStreamServer +// for forward compatibility. +// +// #### Introduction +// +// The Byte Stream API enables a client to read and write a stream of bytes to +// and from a resource. Resources have names, and these names are supplied in +// the API calls below to identify the resource that is being read from or +// written to. +// +// All implementations of the Byte Stream API export the interface defined here: +// +// * `Read()`: Reads the contents of a resource. +// +// - `Write()`: Writes the contents of a resource. The client can call `Write()` +// multiple times with the same resource and can check the status of the write +// by calling `QueryWriteStatus()`. +// +// #### Service parameters and metadata +// +// The ByteStream API provides no direct way to access/modify any metadata +// associated with the resource. +// +// #### Errors +// +// The errors returned by the service are in the Google canonical error space. +type ByteStreamServer interface { + // `Read()` is used to retrieve the contents of a resource as a sequence + // of bytes. The bytes are returned in a sequence of responses, and the + // responses are delivered as the results of a server-side streaming RPC. + Read(*ReadRequest, grpc.ServerStreamingServer[ReadResponse]) error + // `Write()` is used to send the contents of a resource as a sequence of + // bytes. The bytes are sent in a sequence of request protos of a client-side + // streaming RPC. + // + // A `Write()` action is resumable. If there is an error or the connection is + // broken during the `Write()`, the client should check the status of the + // `Write()` by calling `QueryWriteStatus()` and continue writing from the + // returned `committed_size`. This may be less than the amount of data the + // client previously sent. + // + // Calling `Write()` on a resource name that was previously written and + // finalized could cause an error, depending on whether the underlying service + // allows over-writing of previously written resources. + // + // When the client closes the request channel, the service will respond with + // a `WriteResponse`. The service will not view the resource as `complete` + // until the client has sent a `WriteRequest` with `finish_write` set to + // `true`. Sending any requests on a stream after sending a request with + // `finish_write` set to `true` will cause an error. The client **should** + // check the `WriteResponse` it receives to determine how much data the + // service was able to commit and whether the service views the resource as + // `complete` or not. + Write(grpc.ClientStreamingServer[WriteRequest, WriteResponse]) error + // `QueryWriteStatus()` is used to find the `committed_size` for a resource + // that is being written, which can then be used as the `write_offset` for + // the next `Write()` call. + // + // If the resource does not exist (i.e., the resource has been deleted, or the + // first `Write()` has not yet reached the service), this method returns the + // error `NOT_FOUND`. + // + // The client **may** call `QueryWriteStatus()` at any time to determine how + // much data has been processed for this resource. This is useful if the + // client is buffering data and needs to know which data can be safely + // evicted. For any sequence of `QueryWriteStatus()` calls for a given + // resource name, the sequence of returned `committed_size` values will be + // non-decreasing. + QueryWriteStatus(context.Context, *QueryWriteStatusRequest) (*QueryWriteStatusResponse, error) + mustEmbedUnimplementedByteStreamServer() +} + +// UnimplementedByteStreamServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedByteStreamServer struct{} + +func (UnimplementedByteStreamServer) Read(*ReadRequest, grpc.ServerStreamingServer[ReadResponse]) error { + return status.Errorf(codes.Unimplemented, "method Read not implemented") +} +func (UnimplementedByteStreamServer) Write(grpc.ClientStreamingServer[WriteRequest, WriteResponse]) error { + return status.Errorf(codes.Unimplemented, "method Write not implemented") +} +func (UnimplementedByteStreamServer) QueryWriteStatus(context.Context, *QueryWriteStatusRequest) (*QueryWriteStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryWriteStatus not implemented") +} +func (UnimplementedByteStreamServer) mustEmbedUnimplementedByteStreamServer() {} +func (UnimplementedByteStreamServer) testEmbeddedByValue() {} + +// UnsafeByteStreamServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ByteStreamServer will +// result in compilation errors. +type UnsafeByteStreamServer interface { + mustEmbedUnimplementedByteStreamServer() +} + +func RegisterByteStreamServer(s grpc.ServiceRegistrar, srv ByteStreamServer) { + // If the following call pancis, it indicates UnimplementedByteStreamServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ByteStream_ServiceDesc, srv) +} + +func _ByteStream_Read_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ReadRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ByteStreamServer).Read(m, &grpc.GenericServerStream[ReadRequest, ReadResponse]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type ByteStream_ReadServer = grpc.ServerStreamingServer[ReadResponse] + +func _ByteStream_Write_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(ByteStreamServer).Write(&grpc.GenericServerStream[WriteRequest, WriteResponse]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type ByteStream_WriteServer = grpc.ClientStreamingServer[WriteRequest, WriteResponse] + +func _ByteStream_QueryWriteStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryWriteStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ByteStreamServer).QueryWriteStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ByteStream_QueryWriteStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ByteStreamServer).QueryWriteStatus(ctx, req.(*QueryWriteStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ByteStream_ServiceDesc is the grpc.ServiceDesc for ByteStream service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ByteStream_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "google.bytestream.ByteStream", + HandlerType: (*ByteStreamServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "QueryWriteStatus", + Handler: _ByteStream_QueryWriteStatus_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Read", + Handler: _ByteStream_Read_Handler, + ServerStreams: true, + }, + { + StreamName: "Write", + Handler: _ByteStream_Write_Handler, + ClientStreams: true, + }, + }, + Metadata: "google/bytestream/bytestream.proto", +} diff --git a/internal/server/grpc.go b/internal/server/grpc.go new file mode 100644 index 0000000..291cb35 --- /dev/null +++ b/internal/server/grpc.go @@ -0,0 +1,195 @@ +package server + +import ( + "bytes" + "context" + "errors" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + + remoteexecution "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2" + "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/semver" + "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/google/bytestream" +) + +// maxBatchSize bounds a single BatchUpdateBlobs or BatchReadBlobs payload. +// Anything larger has to use the ByteStream API, which streams in chunks instead +// of buffering a whole gRPC message. +const maxBatchSize = 4 * 1024 * 1024 + +// grpcMessageHeadroom leaves room for the framing around a maximum-size batch. +const grpcMessageHeadroom = 1024 * 1024 + +// GRPCHandler returns a gRPC server exposing the cache half of the Bazel remote +// execution API. Remote execution itself is not offered, so Bazel treats the +// endpoint as a cache-only backend. +func (s *Server) GRPCHandler() *grpc.Server { + handler := grpc.NewServer( + grpc.MaxRecvMsgSize(maxBatchSize+grpcMessageHeadroom), + grpc.MaxSendMsgSize(maxBatchSize+grpcMessageHeadroom), + ) + remoteexecution.RegisterCapabilitiesServer(handler, &capabilitiesService{server: s}) + remoteexecution.RegisterActionCacheServer(handler, &actionCacheService{server: s}) + remoteexecution.RegisterContentAddressableStorageServer(handler, &casService{server: s}) + bytestream.RegisterByteStreamServer(handler, &byteStreamService{server: s}) + return handler +} + +// requireDefaultInstance rejects instance names. The cache namespace is fixed by +// the configured key prefix, so honouring an instance name would silently share +// one namespace between callers that asked for different ones. +func requireDefaultInstance(name string) error { + if name != "" { + return status.Errorf(codes.InvalidArgument, "instance_name %q is not supported", name) + } + return nil +} + +func requireSHA256(function remoteexecution.DigestFunction_Value) error { + switch function { + case remoteexecution.DigestFunction_UNKNOWN, remoteexecution.DigestFunction_SHA256: + return nil + default: + return status.Errorf(codes.InvalidArgument, "digest function %s is not supported", function) + } +} + +func requireIdentity(compressor remoteexecution.Compressor_Value) error { + if compressor != remoteexecution.Compressor_IDENTITY { + return status.Errorf(codes.InvalidArgument, "compressor %s is not supported", compressor) + } + return nil +} + +func requestDigest(digest *remoteexecution.Digest, field string) (digestReference, error) { + reference, err := digestReferenceFrom(digest, field) + if err != nil { + return digestReference{}, status.Error(codes.InvalidArgument, err.Error()) + } + return reference, nil +} + +// grpcError translates a cache outcome into the status a REAPI client expects. +func grpcError(kind, digest string, err error) error { + switch { + case errors.Is(err, errCacheMiss): + return status.Errorf(codes.NotFound, "%s/%s is not in the cache", kind, digest) + case errors.Is(err, errPayloadMismatch): + return status.Errorf(codes.InvalidArgument, "payload does not hash to %s", digest) + case errors.Is(err, errPayloadTruncated): + return status.Errorf(codes.InvalidArgument, "payload size does not match %s/%s", kind, digest) + case errors.Is(err, errLocalFailure): + return status.Error(codes.Internal, "local cache unavailable") + default: + return status.Error(codes.Unavailable, "cache backend unavailable") + } +} + +type capabilitiesService struct { + remoteexecution.UnimplementedCapabilitiesServer + server *Server +} + +func (c *capabilitiesService) GetCapabilities( + _ context.Context, + request *remoteexecution.GetCapabilitiesRequest, +) (*remoteexecution.ServerCapabilities, error) { + if err := requireDefaultInstance(request.GetInstanceName()); err != nil { + return nil, err + } + c.server.stats.requests.Add(1) + identity := []remoteexecution.Compressor_Value{remoteexecution.Compressor_IDENTITY} + return remoteexecution.ServerCapabilities_builder{ + CacheCapabilities: remoteexecution.CacheCapabilities_builder{ + DigestFunctions: []remoteexecution.DigestFunction_Value{ + remoteexecution.DigestFunction_SHA256, + }, + ActionCacheUpdateCapabilities: remoteexecution.ActionCacheUpdateCapabilities_builder{ + UpdateEnabled: c.server.cfg.WriteEnabled, + }.Build(), + MaxBatchTotalSizeBytes: maxBatchSize, + MaxCasBlobSizeBytes: c.server.cfg.MaxBlobSize, + // The cache stores action results verbatim and never resolves a + // symlink, so it imposes no restriction on their targets. + SymlinkAbsolutePathStrategy: remoteexecution.SymlinkAbsolutePathStrategy_ALLOWED, + SupportedCompressors: identity, + SupportedBatchUpdateCompressors: identity, + }.Build(), + LowApiVersion: semVer(2, 0), + HighApiVersion: semVer(2, 3), + }.Build(), nil +} + +func semVer(major, minor int32) *semver.SemVer { + return semver.SemVer_builder{Major: major, Minor: minor}.Build() +} + +type actionCacheService struct { + remoteexecution.UnimplementedActionCacheServer + server *Server +} + +func (a *actionCacheService) GetActionResult( + ctx context.Context, + request *remoteexecution.GetActionResultRequest, +) (*remoteexecution.ActionResult, error) { + if err := requireDefaultInstance(request.GetInstanceName()); err != nil { + return nil, err + } + if err := requireSHA256(request.GetDigestFunction()); err != nil { + return nil, err + } + reference, err := requestDigest(request.GetActionDigest(), "action_digest") + if err != nil { + return nil, err + } + a.server.stats.requests.Add(1) + data, err := a.server.readObjectBytes(ctx, "ac", reference.hash) + if err != nil { + return nil, grpcError("ac", reference.hash, err) + } + result := &remoteexecution.ActionResult{} + if err := proto.Unmarshal(data, result); err != nil { + // The closure validation already parsed these bytes, so reaching here + // means the stored entry is unusable rather than merely absent. + a.server.stats.invalidActionResults.Add(1) + return nil, status.Errorf(codes.NotFound, "ac/%s is not in the cache", reference.hash) + } + return result, nil +} + +func (a *actionCacheService) UpdateActionResult( + ctx context.Context, + request *remoteexecution.UpdateActionResultRequest, +) (*remoteexecution.ActionResult, error) { + if err := requireDefaultInstance(request.GetInstanceName()); err != nil { + return nil, err + } + if err := requireSHA256(request.GetDigestFunction()); err != nil { + return nil, err + } + reference, err := requestDigest(request.GetActionDigest(), "action_digest") + if err != nil { + return nil, err + } + result := request.GetActionResult() + if result == nil { + return nil, status.Error(codes.InvalidArgument, "action_result is required") + } + data, err := proto.Marshal(result) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "action_result cannot be encoded: %v", err) + } + if int64(len(data)) > a.server.cfg.MaxBlobSize { + return nil, status.Error(codes.InvalidArgument, "action result exceeds the configured maximum size") + } + a.server.stats.requests.Add(1) + err = a.server.writeObject(ctx, "ac", reference.hash, bytes.NewReader(data), int64(len(data))) + if err != nil { + return nil, grpcError("ac", reference.hash, err) + } + return result, nil +} diff --git a/internal/server/grpc_bytestream.go b/internal/server/grpc_bytestream.go new file mode 100644 index 0000000..8d177db --- /dev/null +++ b/internal/server/grpc_bytestream.go @@ -0,0 +1,235 @@ +package server + +import ( + "context" + "io" + "strconv" + "strings" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/google/bytestream" +) + +// byteStreamChunkSize is the payload size of one Read response. It trades gRPC +// framing overhead against the memory a single in-flight message costs. +const byteStreamChunkSize = 256 * 1024 + +type byteStreamService struct { + bytestream.UnimplementedByteStreamServer + server *Server +} + +func (b *byteStreamService) Read( + request *bytestream.ReadRequest, + stream grpc.ServerStreamingServer[bytestream.ReadResponse], +) error { + resource, err := parseReadResource(request.GetResourceName()) + if err != nil { + return err + } + offset, limit := request.GetReadOffset(), request.GetReadLimit() + if offset < 0 || limit < 0 { + return status.Error(codes.InvalidArgument, "read_offset and read_limit must not be negative") + } + + b.server.stats.requests.Add(1) + if isImplicitEmptyDigest(resource) { + b.server.implicitEmptyCASHit() + return nil + } + file, size, err := b.server.openObject(stream.Context(), "cas", resource.hash) + if err != nil { + return grpcError("cas", resource.hash, err) + } + defer file.Close() + + if offset > size { + return status.Errorf(codes.OutOfRange, "read_offset %d is past the end of the blob", offset) + } + if _, err := file.Seek(offset, io.SeekStart); err != nil { + b.server.cfg.Logger.Printf("seek cache object cas/%s: %v", resource.hash, err) + return status.Error(codes.Internal, "local cache unavailable") + } + var reader io.Reader = file + if limit > 0 { + reader = io.LimitReader(reader, limit) + } + + buffer := make([]byte, byteStreamChunkSize) + for { + n, err := reader.Read(buffer) + if n > 0 { + response := bytestream.ReadResponse_builder{Data: buffer[:n]}.Build() + if sendErr := stream.Send(response); sendErr != nil { + return sendErr + } + b.server.stats.bytesServed.Add(uint64(n)) + } + if err == io.EOF { + return nil + } + if err != nil { + b.server.cfg.Logger.Printf("serve cache object cas/%s: %v", resource.hash, err) + return status.Error(codes.Internal, "local cache unavailable") + } + } +} + +func (b *byteStreamService) Write( + stream grpc.ClientStreamingServer[bytestream.WriteRequest, bytestream.WriteResponse], +) error { + first, err := stream.Recv() + if err == io.EOF { + return status.Error(codes.InvalidArgument, "write stream contained no requests") + } + if err != nil { + return err + } + resource, err := parseWriteResource(first.GetResourceName()) + if err != nil { + return err + } + if first.GetWriteOffset() != 0 { + return status.Error(codes.InvalidArgument, "resumed writes are not supported; write from offset 0") + } + + b.server.stats.requests.Add(1) + if resource.size > b.server.cfg.MaxBlobSize { + return status.Error(codes.InvalidArgument, "blob exceeds the configured maximum size") + } + body := &writeStreamReader{ + stream: stream, + pending: first.GetData(), + offset: int64(len(first.GetData())), + finished: first.GetFinishWrite(), + } + err = b.server.writeObject(stream.Context(), "cas", resource.hash, body, resource.size) + if err != nil { + // A stream-level failure is more specific than the truncation the + // object writer inferred from the short read, so it wins. + if body.err != nil { + return body.err + } + return grpcError("cas", resource.hash, err) + } + return stream.SendAndClose( + bytestream.WriteResponse_builder{CommittedSize: resource.size}.Build(), + ) +} + +// QueryWriteStatus reports that nothing is in flight. Uploads are spooled and +// only become visible once complete, so a client that lost its stream has to +// start again rather than resume. +func (b *byteStreamService) QueryWriteStatus( + _ context.Context, + request *bytestream.QueryWriteStatusRequest, +) (*bytestream.QueryWriteStatusResponse, error) { + b.server.stats.requests.Add(1) + if _, err := parseWriteResource(request.GetResourceName()); err != nil { + return nil, err + } + return nil, status.Error(codes.NotFound, "no write is in progress for this resource") +} + +// writeStreamReader adapts a ByteStream write stream to an io.Reader so that an +// upload is spooled and verified exactly once, by the shared object writer. +type writeStreamReader struct { + stream grpc.ClientStreamingServer[bytestream.WriteRequest, bytestream.WriteResponse] + pending []byte + offset int64 + finished bool + err error +} + +func (r *writeStreamReader) Read(p []byte) (int, error) { + for len(r.pending) == 0 { + if r.finished { + return 0, io.EOF + } + request, err := r.stream.Recv() + if err == io.EOF { + r.err = status.Error(codes.InvalidArgument, "write stream ended before finish_write") + return 0, r.err + } + if err != nil { + r.err = err + return 0, err + } + if request.GetWriteOffset() != r.offset { + r.err = status.Errorf( + codes.InvalidArgument, + "write_offset %d does not continue from %d", + request.GetWriteOffset(), + r.offset, + ) + return 0, r.err + } + r.pending = request.GetData() + r.offset += int64(len(r.pending)) + r.finished = request.GetFinishWrite() + } + n := copy(p, r.pending) + r.pending = r.pending[n:] + return n, nil +} + +// parseReadResource reads `{instance_name}/blobs/{hash}/{size}`. +func parseReadResource(name string) (digestReference, error) { + segments := strings.Split(name, "/") + for i, segment := range segments { + switch segment { + case "blobs": + return blobFromSegments(strings.Join(segments[:i], "/"), segments[i+1:]) + case "compressed-blobs": + return digestReference{}, errCompressedResource + } + } + return digestReference{}, unparsableResource(name) +} + +// parseWriteResource reads +// `{instance_name}/uploads/{uuid}/blobs/{hash}/{size}{/optional_metadata}`. +func parseWriteResource(name string) (digestReference, error) { + segments := strings.Split(name, "/") + for i, segment := range segments { + if segment != "uploads" || i+2 >= len(segments) { + continue + } + switch segments[i+2] { + case "blobs": + return blobFromSegments(strings.Join(segments[:i], "/"), segments[i+3:]) + case "compressed-blobs": + return digestReference{}, errCompressedResource + } + } + return digestReference{}, unparsableResource(name) +} + +func blobFromSegments(instance string, segments []string) (digestReference, error) { + if err := requireDefaultInstance(instance); err != nil { + return digestReference{}, err + } + if len(segments) < 2 { + return digestReference{}, status.Error(codes.InvalidArgument, "resource name has no blob digest") + } + if !digestPattern.MatchString(segments[0]) { + return digestReference{}, status.Error( + codes.InvalidArgument, + "resource name does not carry a lowercase SHA-256 digest", + ) + } + size, err := strconv.ParseInt(segments[1], 10, 64) + if err != nil || size < 0 { + return digestReference{}, status.Error(codes.InvalidArgument, "resource name has no valid blob size") + } + return digestReference{hash: segments[0], size: size}, nil +} + +var errCompressedResource = status.Error(codes.InvalidArgument, "compressed blobs are not supported") + +func unparsableResource(name string) error { + return status.Errorf(codes.InvalidArgument, "resource name %q does not name a CAS blob", name) +} diff --git a/internal/server/grpc_cas.go b/internal/server/grpc_cas.go new file mode 100644 index 0000000..4079413 --- /dev/null +++ b/internal/server/grpc_cas.go @@ -0,0 +1,296 @@ +package server + +import ( + "bytes" + "context" + "errors" + "fmt" + + "golang.org/x/sync/errgroup" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + + remoteexecution "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2" +) + +// treePageSize bounds how many directories are packed into one GetTree response. +const treePageSize = 1024 + +type casService struct { + remoteexecution.UnimplementedContentAddressableStorageServer + server *Server +} + +// FindMissingBlobs is the reason this server speaks gRPC: Bazel probes the whole +// input closure of a build in a handful of calls instead of one HTTP HEAD each. +// The probes still run against the backend, so they are spread over the same +// concurrency budget as every other backend operation. +func (c *casService) FindMissingBlobs( + ctx context.Context, + request *remoteexecution.FindMissingBlobsRequest, +) (*remoteexecution.FindMissingBlobsResponse, error) { + if err := requireDefaultInstance(request.GetInstanceName()); err != nil { + return nil, err + } + if err := requireSHA256(request.GetDigestFunction()); err != nil { + return nil, err + } + digests := request.GetBlobDigests() + references := make([]digestReference, len(digests)) + for i, digest := range digests { + reference, err := requestDigest(digest, "blob_digests") + if err != nil { + return nil, err + } + references[i] = reference + } + + c.server.stats.requests.Add(1) + absent := make([]bool, len(digests)) + group, groupCtx := errgroup.WithContext(ctx) + group.SetLimit(c.server.cfg.MaxConcurrent) + for i, reference := range references { + if isImplicitEmptyDigest(reference) { + c.server.implicitEmptyCASHit() + continue + } + group.Go(func() error { + _, err := c.server.casPresence(groupCtx, reference.hash) + switch { + case err == nil: + return nil + case errors.Is(err, errCacheMiss): + absent[i] = true + return nil + default: + return grpcError("cas", reference.hash, err) + } + }) + } + if err := group.Wait(); err != nil { + return nil, err + } + + var missing []*remoteexecution.Digest + for i, isAbsent := range absent { + if isAbsent { + missing = append(missing, digests[i]) + } + } + return remoteexecution.FindMissingBlobsResponse_builder{MissingBlobDigests: missing}.Build(), nil +} + +func (c *casService) BatchUpdateBlobs( + ctx context.Context, + request *remoteexecution.BatchUpdateBlobsRequest, +) (*remoteexecution.BatchUpdateBlobsResponse, error) { + if err := requireDefaultInstance(request.GetInstanceName()); err != nil { + return nil, err + } + if err := requireSHA256(request.GetDigestFunction()); err != nil { + return nil, err + } + blobs := request.GetRequests() + var total int64 + for _, blob := range blobs { + total += int64(len(blob.GetData())) + } + if total > maxBatchSize { + return nil, status.Errorf( + codes.InvalidArgument, + "batch of %d bytes exceeds the %d byte limit", + total, + maxBatchSize, + ) + } + + c.server.stats.requests.Add(1) + responses := make([]*remoteexecution.BatchUpdateBlobsResponse_Response, len(blobs)) + for i, blob := range blobs { + digest := blob.GetDigest() + responses[i] = remoteexecution.BatchUpdateBlobsResponse_Response_builder{ + Digest: digest, + Status: status.Convert(c.updateBlob(ctx, blob)).Proto(), + }.Build() + } + return remoteexecution.BatchUpdateBlobsResponse_builder{Responses: responses}.Build(), nil +} + +func (c *casService) updateBlob( + ctx context.Context, + blob *remoteexecution.BatchUpdateBlobsRequest_Request, +) error { + if err := requireIdentity(blob.GetCompressor()); err != nil { + return err + } + reference, err := requestDigest(blob.GetDigest(), "digest") + if err != nil { + return err + } + data := blob.GetData() + if int64(len(data)) != reference.size { + return status.Errorf( + codes.InvalidArgument, + "blob is %d bytes; digest declares %d", + len(data), + reference.size, + ) + } + if reference.size > c.server.cfg.MaxBlobSize { + return status.Error(codes.InvalidArgument, "blob exceeds the configured maximum size") + } + err = c.server.writeObject(ctx, "cas", reference.hash, bytes.NewReader(data), reference.size) + if err != nil { + return grpcError("cas", reference.hash, err) + } + return nil +} + +func (c *casService) BatchReadBlobs( + ctx context.Context, + request *remoteexecution.BatchReadBlobsRequest, +) (*remoteexecution.BatchReadBlobsResponse, error) { + if err := requireDefaultInstance(request.GetInstanceName()); err != nil { + return nil, err + } + if err := requireSHA256(request.GetDigestFunction()); err != nil { + return nil, err + } + for _, compressor := range request.GetAcceptableCompressors() { + if err := requireIdentity(compressor); err != nil { + return nil, err + } + } + digests := request.GetDigests() + var total int64 + for _, digest := range digests { + total += digest.GetSizeBytes() + } + if total > maxBatchSize { + return nil, status.Errorf( + codes.InvalidArgument, + "batch of %d bytes exceeds the %d byte limit", + total, + maxBatchSize, + ) + } + + c.server.stats.requests.Add(1) + responses := make([]*remoteexecution.BatchReadBlobsResponse_Response, len(digests)) + for i, digest := range digests { + data, err := c.readBlob(ctx, digest) + responses[i] = remoteexecution.BatchReadBlobsResponse_Response_builder{ + Digest: digest, + Data: data, + Status: status.Convert(err).Proto(), + }.Build() + } + return remoteexecution.BatchReadBlobsResponse_builder{Responses: responses}.Build(), nil +} + +func (c *casService) readBlob(ctx context.Context, digest *remoteexecution.Digest) ([]byte, error) { + reference, err := requestDigest(digest, "digests") + if err != nil { + return nil, err + } + if isImplicitEmptyDigest(reference) { + c.server.implicitEmptyCASHit() + return nil, nil + } + data, err := c.server.readObjectBytes(ctx, "cas", reference.hash) + if err != nil { + return nil, grpcError("cas", reference.hash, err) + } + return data, nil +} + +// GetTree walks an output directory that was stored as individual Directory +// objects rather than as a single Tree. +func (c *casService) GetTree( + request *remoteexecution.GetTreeRequest, + stream grpc.ServerStreamingServer[remoteexecution.GetTreeResponse], +) error { + if err := requireDefaultInstance(request.GetInstanceName()); err != nil { + return err + } + if err := requireSHA256(request.GetDigestFunction()); err != nil { + return err + } + if request.GetPageToken() != "" { + return status.Error(codes.InvalidArgument, "page tokens are not supported") + } + root, err := requestDigest(request.GetRootDigest(), "root_digest") + if err != nil { + return err + } + + ctx := stream.Context() + c.server.stats.requests.Add(1) + queue := []digestReference{root} + visited := map[string]struct{}{root.hash: {}} + page := make([]*remoteexecution.Directory, 0, treePageSize) + for len(queue) > 0 { + reference := queue[0] + queue = queue[1:] + if len(visited) > maxActionResultObjects { + return status.Errorf( + codes.ResourceExhausted, + "tree references more than %d directories", + maxActionResultObjects, + ) + } + directory, err := c.loadDirectory(ctx, reference) + if err != nil { + return err + } + page = append(page, directory) + for _, child := range directory.GetDirectories() { + childReference, err := requestDigest(child.GetDigest(), "directory_node.digest") + if err != nil { + return err + } + if _, seen := visited[childReference.hash]; seen { + continue + } + visited[childReference.hash] = struct{}{} + queue = append(queue, childReference) + } + if len(page) == treePageSize { + if err := sendTreePage(stream, page); err != nil { + return err + } + page = page[:0] + } + } + if len(page) == 0 { + return nil + } + return sendTreePage(stream, page) +} + +func (c *casService) loadDirectory( + ctx context.Context, + reference digestReference, +) (*remoteexecution.Directory, error) { + data, err := c.server.readObjectBytes(ctx, "cas", reference.hash) + if err != nil { + return nil, grpcError("cas", reference.hash, err) + } + directory := &remoteexecution.Directory{} + if err := proto.Unmarshal(data, directory); err != nil { + return nil, status.Error( + codes.NotFound, + fmt.Sprintf("cas/%s is not a directory", reference.hash), + ) + } + return directory, nil +} + +func sendTreePage( + stream grpc.ServerStreamingServer[remoteexecution.GetTreeResponse], + page []*remoteexecution.Directory, +) error { + return stream.Send(remoteexecution.GetTreeResponse_builder{Directories: page}.Build()) +} diff --git a/internal/server/grpc_test.go b/internal/server/grpc_test.go new file mode 100644 index 0000000..51974c5 --- /dev/null +++ b/internal/server/grpc_test.go @@ -0,0 +1,525 @@ +package server + +import ( + "context" + "errors" + "io" + "net" + "strconv" + "strings" + "testing" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" + "google.golang.org/grpc/test/bufconn" + "google.golang.org/protobuf/proto" + + remoteexecution "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/build/bazel/remote/execution/v2" + "github.com/cre4ture/bazel-github-actions-cache-v2/internal/proto/gen/google/bytestream" +) + +func testGRPCConn(t *testing.T, server *Server) *grpc.ClientConn { + t.Helper() + listener := bufconn.Listen(1024 * 1024) + handler := server.GRPCHandler() + go func() { _ = handler.Serve(listener) }() + t.Cleanup(handler.Stop) + + conn, err := grpc.NewClient( + "passthrough:///bufnet", + grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) { + return listener.DialContext(ctx) + }), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = conn.Close() }) + return conn +} + +func assertCode(t *testing.T, err error, want codes.Code) { + t.Helper() + if status.Code(err) != want { + t.Fatalf("code = %s (%v), want %s", status.Code(err), err, want) + } +} + +func readResource(reference digestReference) string { + return "blobs/" + reference.hash + "/" + strconv.FormatInt(reference.size, 10) +} + +func writeResource(reference digestReference) string { + return "uploads/8c6ded1a-0f5e-4f2b-9c10-3a5f1d8b7e42/blobs/" + + reference.hash + "/" + strconv.FormatInt(reference.size, 10) +} + +func TestGRPCCapabilitiesAdvertiseSHA256AndWriteState(t *testing.T) { + for _, writeEnabled := range []bool{true, false} { + server := testServer(t, newMemoryBackend(), func(cfg *Config) { + cfg.WriteEnabled = writeEnabled + }) + client := remoteexecution.NewCapabilitiesClient(testGRPCConn(t, server)) + + capabilities, err := client.GetCapabilities( + t.Context(), + remoteexecution.GetCapabilitiesRequest_builder{}.Build(), + ) + if err != nil { + t.Fatal(err) + } + cache := capabilities.GetCacheCapabilities() + functions := cache.GetDigestFunctions() + if len(functions) != 1 || functions[0] != remoteexecution.DigestFunction_SHA256 { + t.Fatalf("digest functions = %v", functions) + } + if got := cache.GetActionCacheUpdateCapabilities().GetUpdateEnabled(); got != writeEnabled { + t.Fatalf("update_enabled = %t, want %t", got, writeEnabled) + } + if cache.GetMaxBatchTotalSizeBytes() != maxBatchSize { + t.Fatalf("max_batch_total_size_bytes = %d", cache.GetMaxBatchTotalSizeBytes()) + } + if capabilities.GetExecutionCapabilities() != nil { + t.Fatal("cache-only server advertised execution capabilities") + } + } +} + +func TestGRPCRejectsInstanceNames(t *testing.T) { + server := testServer(t, newMemoryBackend(), nil) + conn := testGRPCConn(t, server) + + _, err := remoteexecution.NewCapabilitiesClient(conn).GetCapabilities( + t.Context(), + remoteexecution.GetCapabilitiesRequest_builder{InstanceName: "other"}.Build(), + ) + assertCode(t, err, codes.InvalidArgument) + + _, err = remoteexecution.NewActionCacheClient(conn).GetActionResult( + t.Context(), + remoteexecution.GetActionResultRequest_builder{ + InstanceName: "other", + ActionDigest: digestProto(referenceFor([]byte("action"))), + }.Build(), + ) + assertCode(t, err, codes.InvalidArgument) +} + +func TestGRPCActionCacheRoundTripRequiresCompleteClosure(t *testing.T) { + output := []byte("grpc cached output") + outputReference := referenceFor(output) + actionDigest := digestProto(digestReference{hash: strings.Repeat("a", 64), size: 7}) + result := remoteexecution.ActionResult_builder{ + OutputFiles: []*remoteexecution.OutputFile{outputFileProto(outputReference, nil)}, + }.Build() + + t.Run("complete", func(t *testing.T) { + backend := newMemoryBackend() + backend.objects["test-v1-cas-"+outputReference.hash] = output + server := testServer(t, backend, nil) + client := remoteexecution.NewActionCacheClient(testGRPCConn(t, server)) + + _, err := client.UpdateActionResult(t.Context(), remoteexecution.UpdateActionResultRequest_builder{ + ActionDigest: actionDigest, + ActionResult: result, + }.Build()) + if err != nil { + t.Fatal(err) + } + got, err := client.GetActionResult(t.Context(), remoteexecution.GetActionResultRequest_builder{ + ActionDigest: actionDigest, + }.Build()) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(got, result) { + t.Fatalf("action result = %v, want %v", got, result) + } + }) + + t.Run("missing output", func(t *testing.T) { + server := testServer(t, newMemoryBackend(), nil) + client := remoteexecution.NewActionCacheClient(testGRPCConn(t, server)) + + // The upload is accepted but never published, so the read misses. + if _, err := client.UpdateActionResult(t.Context(), remoteexecution.UpdateActionResultRequest_builder{ + ActionDigest: actionDigest, + ActionResult: result, + }.Build()); err != nil { + t.Fatal(err) + } + _, err := client.GetActionResult(t.Context(), remoteexecution.GetActionResultRequest_builder{ + ActionDigest: actionDigest, + }.Build()) + assertCode(t, err, codes.NotFound) + if stats := server.Snapshot(); stats.SkippedActionResultUploads != 1 { + t.Fatalf("unexpected stats: %+v", stats) + } + }) +} + +func TestGRPCFindMissingBlobsBatchesPresenceChecks(t *testing.T) { + present := []byte("present blob") + presentReference := referenceFor(present) + absentReference := referenceFor([]byte("absent blob")) + emptyReference := referenceFor(nil) + + backend := newMemoryBackend() + backend.objects["test-v1-cas-"+presentReference.hash] = present + server := testServer(t, backend, nil) + client := remoteexecution.NewContentAddressableStorageClient(testGRPCConn(t, server)) + + response, err := client.FindMissingBlobs(t.Context(), remoteexecution.FindMissingBlobsRequest_builder{ + BlobDigests: []*remoteexecution.Digest{ + digestProto(presentReference), + digestProto(absentReference), + digestProto(emptyReference), + }, + }.Build()) + if err != nil { + t.Fatal(err) + } + missing := response.GetMissingBlobDigests() + if len(missing) != 1 || missing[0].GetHash() != absentReference.hash { + t.Fatalf("missing = %v, want only %s", missing, absentReference.hash) + } + // The empty digest is answered locally; only the other two reach the backend. + if calls := backend.existsCount(); calls != 2 { + t.Fatalf("backend existence checks = %d, want 2", calls) + } +} + +func TestGRPCBatchUpdateAndReadBlobs(t *testing.T) { + blob := []byte("batched blob") + reference := referenceFor(blob) + mismatched := referenceFor([]byte("different blob")) + server := testServer(t, newMemoryBackend(), nil) + client := remoteexecution.NewContentAddressableStorageClient(testGRPCConn(t, server)) + + update, err := client.BatchUpdateBlobs(t.Context(), remoteexecution.BatchUpdateBlobsRequest_builder{ + Requests: []*remoteexecution.BatchUpdateBlobsRequest_Request{ + remoteexecution.BatchUpdateBlobsRequest_Request_builder{ + Digest: digestProto(reference), + Data: blob, + }.Build(), + remoteexecution.BatchUpdateBlobsRequest_Request_builder{ + Digest: digestProto(digestReference{hash: mismatched.hash, size: reference.size}), + Data: blob, + }.Build(), + }, + }.Build()) + if err != nil { + t.Fatal(err) + } + responses := update.GetResponses() + if len(responses) != 2 { + t.Fatalf("responses = %d, want 2", len(responses)) + } + if code := codes.Code(responses[0].GetStatus().GetCode()); code != codes.OK { + t.Fatalf("first upload status = %s", code) + } + if code := codes.Code(responses[1].GetStatus().GetCode()); code != codes.InvalidArgument { + t.Fatalf("mismatched upload status = %s, want InvalidArgument", code) + } + + read, err := client.BatchReadBlobs(t.Context(), remoteexecution.BatchReadBlobsRequest_builder{ + Digests: []*remoteexecution.Digest{ + digestProto(reference), + digestProto(referenceFor([]byte("never uploaded"))), + }, + }.Build()) + if err != nil { + t.Fatal(err) + } + items := read.GetResponses() + if len(items) != 2 { + t.Fatalf("responses = %d, want 2", len(items)) + } + if string(items[0].GetData()) != string(blob) { + t.Fatalf("blob = %q", items[0].GetData()) + } + if code := codes.Code(items[1].GetStatus().GetCode()); code != codes.NotFound { + t.Fatalf("absent blob status = %s, want NotFound", code) + } +} + +func TestGRPCBatchRejectsOversizedRequests(t *testing.T) { + server := testServer(t, newMemoryBackend(), nil) + client := remoteexecution.NewContentAddressableStorageClient(testGRPCConn(t, server)) + + _, err := client.BatchReadBlobs(t.Context(), remoteexecution.BatchReadBlobsRequest_builder{ + Digests: []*remoteexecution.Digest{ + digestProto(digestReference{hash: strings.Repeat("b", 64), size: maxBatchSize + 1}), + }, + }.Build()) + assertCode(t, err, codes.InvalidArgument) +} + +// Probing the same blobs over either transport must touch the same number of +// objects and the same number of backend entries; only the number of client +// calls differs, which is what makes batching visible in the statistics. +func TestAccountingSeparatesCallsFromObjectsAndBackendEntries(t *testing.T) { + present := []byte("present blob") + presentReference := referenceFor(present) + absent := referenceFor([]byte("absent blob")) + empty := referenceFor(nil) + + newServer := func(t *testing.T) *Server { + backend := newMemoryBackend() + backend.objects["test-v1-cas-"+presentReference.hash] = present + return testServer(t, backend, nil) + } + + t.Run("http", func(t *testing.T) { + server := newServer(t) + for _, reference := range []digestReference{presentReference, absent, empty} { + headCacheObject(server, "/cas/"+reference.hash) + } + stats := server.Snapshot() + if stats.Requests != 3 || stats.Operations != 3 || stats.BackendRequests != 2 { + t.Fatalf("unexpected stats: %+v", stats) + } + }) + + t.Run("grpc", func(t *testing.T) { + server := newServer(t) + client := remoteexecution.NewContentAddressableStorageClient(testGRPCConn(t, server)) + _, err := client.FindMissingBlobs(t.Context(), remoteexecution.FindMissingBlobsRequest_builder{ + BlobDigests: []*remoteexecution.Digest{ + digestProto(presentReference), + digestProto(absent), + digestProto(empty), + }, + }.Build()) + if err != nil { + t.Fatal(err) + } + stats := server.Snapshot() + if stats.Requests != 1 || stats.Operations != 3 || stats.BackendRequests != 2 { + t.Fatalf("unexpected stats: %+v", stats) + } + }) +} + +func TestGRPCByteStreamRoundTrip(t *testing.T) { + blob := []byte("a reasonably long byte stream payload") + reference := referenceFor(blob) + server := testServer(t, newMemoryBackend(), nil) + client := bytestream.NewByteStreamClient(testGRPCConn(t, server)) + + stream, err := client.Write(t.Context()) + if err != nil { + t.Fatal(err) + } + split := 10 + send := func(offset int64, data []byte, finish bool) { + t.Helper() + err := stream.Send(bytestream.WriteRequest_builder{ + ResourceName: writeResource(reference), + WriteOffset: offset, + Data: data, + FinishWrite: finish, + }.Build()) + if err != nil { + t.Fatal(err) + } + } + send(0, blob[:split], false) + send(int64(split), blob[split:], true) + response, err := stream.CloseAndRecv() + if err != nil { + t.Fatal(err) + } + if response.GetCommittedSize() != reference.size { + t.Fatalf("committed_size = %d, want %d", response.GetCommittedSize(), reference.size) + } + + for _, test := range []struct { + name string + offset int64 + limit int64 + want string + }{ + {name: "whole blob", want: string(blob)}, + {name: "from offset", offset: 2, want: string(blob[2:])}, + {name: "limited", limit: 6, want: string(blob[:6])}, + } { + t.Run(test.name, func(t *testing.T) { + reads, err := client.Read(t.Context(), bytestream.ReadRequest_builder{ + ResourceName: readResource(reference), + ReadOffset: test.offset, + ReadLimit: test.limit, + }.Build()) + if err != nil { + t.Fatal(err) + } + var got []byte + for { + chunk, err := reads.Recv() + if errors.Is(err, io.EOF) { + break + } + if err != nil { + t.Fatal(err) + } + got = append(got, chunk.GetData()...) + } + if string(got) != test.want { + t.Fatalf("read = %q, want %q", got, test.want) + } + }) + } +} + +func TestGRPCByteStreamRejectsMalformedWrites(t *testing.T) { + blob := []byte("stream payload") + reference := referenceFor(blob) + server := testServer(t, newMemoryBackend(), nil) + client := bytestream.NewByteStreamClient(testGRPCConn(t, server)) + + write := func(t *testing.T, requests ...*bytestream.WriteRequest) error { + t.Helper() + stream, err := client.Write(t.Context()) + if err != nil { + t.Fatal(err) + } + for _, request := range requests { + if err := stream.Send(request); err != nil { + break + } + } + _, err = stream.CloseAndRecv() + return err + } + + t.Run("digest mismatch", func(t *testing.T) { + other := referenceFor([]byte("something else")) + err := write(t, bytestream.WriteRequest_builder{ + ResourceName: writeResource(digestReference{hash: other.hash, size: reference.size}), + Data: blob, + FinishWrite: true, + }.Build()) + assertCode(t, err, codes.InvalidArgument) + }) + + t.Run("non-contiguous offset", func(t *testing.T) { + err := write(t, + bytestream.WriteRequest_builder{ + ResourceName: writeResource(reference), + Data: blob[:4], + }.Build(), + bytestream.WriteRequest_builder{ + ResourceName: writeResource(reference), + WriteOffset: 99, + Data: blob[4:], + FinishWrite: true, + }.Build(), + ) + assertCode(t, err, codes.InvalidArgument) + }) + + t.Run("ended before finish_write", func(t *testing.T) { + err := write(t, bytestream.WriteRequest_builder{ + ResourceName: writeResource(reference), + Data: blob[:4], + }.Build()) + assertCode(t, err, codes.InvalidArgument) + }) + + t.Run("compressed resource", func(t *testing.T) { + err := write(t, bytestream.WriteRequest_builder{ + ResourceName: "uploads/id/compressed-blobs/zstd/" + reference.hash + "/14", + Data: blob, + FinishWrite: true, + }.Build()) + assertCode(t, err, codes.InvalidArgument) + }) +} + +func TestGRPCByteStreamReadRejectsOutOfRangeOffset(t *testing.T) { + blob := []byte("short") + reference := referenceFor(blob) + backend := newMemoryBackend() + backend.objects["test-v1-cas-"+reference.hash] = blob + server := testServer(t, backend, nil) + client := bytestream.NewByteStreamClient(testGRPCConn(t, server)) + + stream, err := client.Read(t.Context(), bytestream.ReadRequest_builder{ + ResourceName: readResource(reference), + ReadOffset: reference.size + 1, + }.Build()) + if err != nil { + t.Fatal(err) + } + _, err = stream.Recv() + assertCode(t, err, codes.OutOfRange) +} + +func TestGRPCQueryWriteStatusReportsNoProgress(t *testing.T) { + server := testServer(t, newMemoryBackend(), nil) + client := bytestream.NewByteStreamClient(testGRPCConn(t, server)) + + _, err := client.QueryWriteStatus(t.Context(), bytestream.QueryWriteStatusRequest_builder{ + ResourceName: writeResource(referenceFor([]byte("anything"))), + }.Build()) + assertCode(t, err, codes.NotFound) +} + +func TestGRPCGetTreeStreamsNestedDirectories(t *testing.T) { + file := referenceFor([]byte("nested file")) + child := marshalProto(t, remoteexecution.Directory_builder{ + Files: []*remoteexecution.FileNode{fileNodeProto(file)}, + }.Build()) + childReference := referenceFor(child) + root := marshalProto(t, remoteexecution.Directory_builder{ + Directories: []*remoteexecution.DirectoryNode{directoryNodeProto(childReference)}, + }.Build()) + rootReference := referenceFor(root) + + backend := newMemoryBackend() + backend.objects["test-v1-cas-"+rootReference.hash] = root + backend.objects["test-v1-cas-"+childReference.hash] = child + server := testServer(t, backend, nil) + client := remoteexecution.NewContentAddressableStorageClient(testGRPCConn(t, server)) + + stream, err := client.GetTree(t.Context(), remoteexecution.GetTreeRequest_builder{ + RootDigest: digestProto(rootReference), + }.Build()) + if err != nil { + t.Fatal(err) + } + var directories []*remoteexecution.Directory + for { + page, err := stream.Recv() + if errors.Is(err, io.EOF) { + break + } + if err != nil { + t.Fatal(err) + } + directories = append(directories, page.GetDirectories()...) + } + if len(directories) != 2 { + t.Fatalf("directories = %d, want 2", len(directories)) + } + if got := directories[1].GetFiles(); len(got) != 1 || got[0].GetDigest().GetHash() != file.hash { + t.Fatalf("child directory = %v", directories[1]) + } +} + +func TestGRPCGetTreeRejectsMissingRoot(t *testing.T) { + server := testServer(t, newMemoryBackend(), nil) + client := remoteexecution.NewContentAddressableStorageClient(testGRPCConn(t, server)) + + stream, err := client.GetTree(t.Context(), remoteexecution.GetTreeRequest_builder{ + RootDigest: digestProto(referenceFor([]byte("absent root"))), + }.Build()) + if err != nil { + t.Fatal(err) + } + _, err = stream.Recv() + assertCode(t, err, codes.NotFound) +} diff --git a/internal/server/objects.go b/internal/server/objects.go index 556338a..9143b94 100644 --- a/internal/server/objects.go +++ b/internal/server/objects.go @@ -38,6 +38,7 @@ func (s *Server) degrade(failure error) error { // readObject resolves an object and, for action results, validates that its CAS // closure is still complete. func (s *Server) readObject(ctx context.Context, kind, digest string) (object, error) { + s.stats.operations.Add(1) obj, found, err := s.resolve(ctx, s.objectKey(kind, digest), kind, digest) if err != nil { s.stats.backendLoadErrors.Add(1) @@ -81,6 +82,7 @@ func (s *Server) openObject(ctx context.Context, kind, digest string) (*os.File, // mode allows it. Bazel issues these while building without needing the bytes, // so restoring a whole pack to answer one would defeat the point. func (s *Server) casPresence(ctx context.Context, digest string) (int64, error) { + s.stats.operations.Add(1) size, found, err := s.presence(ctx, s.objectKey("cas", digest)) if err != nil { s.cfg.Logger.Printf("presence check for cas/%s failed: %s", digest, safeError(err)) @@ -93,6 +95,31 @@ func (s *Server) casPresence(ctx context.Context, digest string) (int64, error) return size, nil } +// implicitEmptyCASHit records the zero-byte CAS digest, which every transport +// answers from the digest alone without consulting storage. +func (s *Server) implicitEmptyCASHit() { + s.stats.operations.Add(1) + s.stats.hits.Add(1) +} + +// readObjectBytes returns a whole object. Callers are responsible for bounding +// the size beforehand, so it suits action results, directories, and batched +// blobs rather than arbitrary CAS reads. +func (s *Server) readObjectBytes(ctx context.Context, kind, digest string) ([]byte, error) { + file, size, err := s.openObject(ctx, kind, digest) + if err != nil { + return nil, err + } + defer file.Close() + data := make([]byte, size) + if _, err := io.ReadFull(file, data); err != nil { + s.cfg.Logger.Printf("read local cache object %s/%s: %v", kind, digest, err) + return nil, errLocalFailure + } + s.stats.bytesServed.Add(uint64(len(data))) + return data, nil +} + func (s *Server) validateStoredActionResult(ctx context.Context, digest string, obj object) error { err := s.validateActionResult(ctx, obj) switch { @@ -126,6 +153,7 @@ func (s *Server) writeObject( body io.Reader, size int64, ) error { + s.stats.operations.Add(1) file, err := os.CreateTemp(s.cfg.CacheDir, "upload-*") if err != nil { s.cfg.Logger.Printf("create upload spool for %s/%s: %v", kind, digest, err) diff --git a/internal/server/server.go b/internal/server/server.go index abbb897..0e51de7 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -17,6 +17,7 @@ import ( "strconv" "strings" "sync" + "sync/atomic" "time" "github.com/cre4ture/bazel-github-actions-cache-v2/internal/cache" @@ -149,6 +150,10 @@ func New(cfg Config) (*Server, error) { sem: make(chan struct{}, cfg.MaxConcurrent), limiter: newIntervalLimiter(cfg.UploadsPerMinute), } + server.cfg.Backend = &countingBackend{ + backend: cfg.Backend, + counter: &server.stats.backendRequests, + } if cfg.StorageMode == "packs" { packs, err := newPackStore(server) if err != nil { @@ -159,6 +164,30 @@ func New(cfg Config) (*Server, error) { return server, nil } +// countingBackend records every call into the GitHub Actions cache. Counting at +// this boundary rather than at each call site keeps the total honest: closure +// validation, packed reads, and retries all reach the API without a matching +// client request. +type countingBackend struct { + backend cache.Backend + counter *atomic.Uint64 +} + +func (b *countingBackend) Exists(ctx context.Context, key string) (bool, error) { + b.counter.Add(1) + return b.backend.Exists(ctx, key) +} + +func (b *countingBackend) Load(ctx context.Context, key string, dst io.Writer) (bool, error) { + b.counter.Add(1) + return b.backend.Load(ctx, key, dst) +} + +func (b *countingBackend) Save(ctx context.Context, key string, src *os.File, size int64) error { + b.counter.Add(1) + return b.backend.Save(ctx, key, src, size) +} + func (s *Server) Handler() http.Handler { return http.HandlerFunc(s.serveHTTP) } @@ -248,7 +277,7 @@ func (s *Server) handleHead(w http.ResponseWriter, r *http.Request, kind, digest } func (s *Server) handleImplicitEmptyCASRead(w http.ResponseWriter, r *http.Request) { - s.stats.hits.Add(1) + s.implicitEmptyCASHit() s.writeObjectHeader(w, 0) } diff --git a/internal/server/stats.go b/internal/server/stats.go index 25730ff..962aa4a 100644 --- a/internal/server/stats.go +++ b/internal/server/stats.go @@ -8,11 +8,13 @@ import ( // Stats is a point-in-time JSON representation of cache activity. type Stats struct { Requests uint64 `json:"requests"` + Operations uint64 `json:"operations"` Hits uint64 `json:"hits"` Misses uint64 `json:"misses"` Uploads uint64 `json:"uploads"` DeduplicatedUploads uint64 `json:"deduplicated_uploads"` DiscardedUploads uint64 `json:"discarded_uploads"` + BackendRequests uint64 `json:"backend_requests"` BackendDownloads uint64 `json:"backend_downloads"` BackendExistenceChecks uint64 `json:"backend_existence_checks"` BackendLoadErrors uint64 `json:"backend_load_errors"` @@ -43,11 +45,13 @@ type Stats struct { type counters struct { requests atomic.Uint64 + operations atomic.Uint64 hits atomic.Uint64 misses atomic.Uint64 uploads atomic.Uint64 deduplicatedUploads atomic.Uint64 discardedUploads atomic.Uint64 + backendRequests atomic.Uint64 backendDownloads atomic.Uint64 backendExistenceChecks atomic.Uint64 backendLoadErrors atomic.Uint64 @@ -79,11 +83,13 @@ type counters struct { func (c *counters) snapshot() Stats { return Stats{ Requests: c.requests.Load(), + Operations: c.operations.Load(), Hits: c.hits.Load(), Misses: c.misses.Load(), Uploads: c.uploads.Load(), DeduplicatedUploads: c.deduplicatedUploads.Load(), DiscardedUploads: c.discardedUploads.Load(), + BackendRequests: c.backendRequests.Load(), BackendDownloads: c.backendDownloads.Load(), BackendExistenceChecks: c.backendExistenceChecks.Load(), BackendLoadErrors: c.backendLoadErrors.Load(), diff --git a/scripts/generate-proto.sh b/scripts/generate-proto.sh index 0a7d4bd..df4c2f0 100755 --- a/scripts/generate-proto.sh +++ b/scripts/generate-proto.sh @@ -12,7 +12,7 @@ project_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) # Keep protoc_gen_go_version in sync with google.golang.org/protobuf in go.mod and # grpc_version in sync with google.golang.org/grpc. buf_version=v1.73.0 -protoc_gen_go_version=v1.36.11 +protoc_gen_go_version=v1.36.12 protoc_gen_go_grpc_version=v1.5.1 # bazelbuild/remote-apis tag v2.12.0. From 61670a8226be58404769fb5dc0a0345266b08b87 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 21 Sep 2026 00:41:20 +1000 Subject: [PATCH 09/55] Source server binaries from releases rather than version control (#12) * Source server binaries from releases rather than version control * Validate tag inputs --- .github/actions/publish-release/action.yml | 77 ++++++++ .github/workflows/ci.yml | 11 +- .github/workflows/pre-release.yml | 42 +++++ .github/workflows/release.yml | 68 +++++++ .github/workflows/smoke.yml | 10 + .gitignore | 2 +- CONTRIBUTING.md | 7 +- README.md | 47 ++++- action/main.js | 19 +- action/release.js | 186 ++++++++++++++++++ action/release.test.js | 209 +++++++++++++++++++++ dist/SHA256SUMS | 2 - dist/cache-server-linux-amd64 | Bin 9744510 -> 0 bytes dist/cache-server-linux-arm64 | Bin 9044094 -> 0 bytes 14 files changed, 662 insertions(+), 18 deletions(-) create mode 100644 .github/actions/publish-release/action.yml create mode 100644 .github/workflows/pre-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 action/release.js create mode 100644 action/release.test.js delete mode 100644 dist/SHA256SUMS delete mode 100755 dist/cache-server-linux-amd64 delete mode 100755 dist/cache-server-linux-arm64 diff --git a/.github/actions/publish-release/action.yml b/.github/actions/publish-release/action.yml new file mode 100644 index 0000000..df21559 --- /dev/null +++ b/.github/actions/publish-release/action.yml @@ -0,0 +1,77 @@ +name: Publish release +description: >- + Builds the server binaries, attests their provenance, and publishes them as + assets on a tag pointing at the commit they were built from. + +inputs: + version: + description: Release tag to create + required: true + prerelease: + description: Mark the release as a pre-release + required: false + default: "false" + notes: + description: Release notes body + required: true + token: + description: Token used to create the tag and publish the release + required: true + +runs: + using: composite + steps: + - name: Build server binaries + shell: bash + env: + VERSION: ${{ inputs.version }} + run: scripts/build-dist.sh + + # The action verifies this attestation before it will run a downloaded + # binary, which is what lets the repository ship no build output at all. + - name: Attest the build provenance + uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 + with: + subject-path: | + dist/cache-server-linux-amd64 + dist/cache-server-linux-arm64 + + # The tag points at the reviewed commit itself, so the tree a consumer + # checks out is exactly the tree CI ran against. + - name: Tag the release + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + VERSION: ${{ inputs.version }} + REPOSITORY: ${{ github.repository }} + BASE_SHA: ${{ github.sha }} + run: | + set -euo pipefail + gh api --method POST "repos/$REPOSITORY/git/refs" \ + --field ref="refs/tags/$VERSION" --field sha="$BASE_SHA" >/dev/null + + # Immutable releases lock assets at publication, so the release is drafted, + # populated, and only then published. + - name: Publish the release + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + VERSION: ${{ inputs.version }} + NOTES: ${{ inputs.notes }} + PRERELEASE: ${{ inputs.prerelease }} + run: | + set -euo pipefail + create=(gh release create "$VERSION" --draft --verify-tag --title "$VERSION" --notes "$NOTES") + if [[ "$PRERELEASE" == "true" ]]; then + create+=(--prerelease) + fi + "${create[@]}" + gh release upload "$VERSION" \ + dist/cache-server-linux-amd64 \ + dist/cache-server-linux-arm64 \ + dist/SHA256SUMS + publish=(gh release edit "$VERSION" --draft=false) + if [[ "$PRERELEASE" != "true" ]]; then + publish+=(--latest) + fi + "${publish[@]}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30e21e9..4da01ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,9 +30,14 @@ jobs: run: node --test action/*.test.js - name: Actionlint run: go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 - - name: Rebuild packaged binaries + - name: Build packaged binaries env: - VERSION: v0.3.2 + VERSION: ci-${{ github.sha }} run: scripts/build-dist.sh - name: Verify packaged binaries are reproducible - run: git diff --exit-code -- dist + env: + VERSION: ci-${{ github.sha }} + run: | + mv dist/SHA256SUMS "$RUNNER_TEMP/SHA256SUMS.first" + scripts/build-dist.sh + diff "$RUNNER_TEMP/SHA256SUMS.first" dist/SHA256SUMS diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..659b463 --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,42 @@ +name: Pre-release + +on: + push: + branches: [main] + paths-ignore: + - "**/*.md" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pre-release + cancel-in-progress: false + +jobs: + pre-release: + runs-on: ubuntu-24.04 + permissions: + contents: write + id-token: write + attestations: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: .go-version + cache: true + - name: Choose a timestamped version + id: version + run: echo "version=pre-$(date -u +%Y%m%dT%H%M%SZ)" >> "$GITHUB_OUTPUT" + - name: Publish + uses: ./.github/actions/publish-release + with: + version: ${{ steps.version.outputs.version }} + prerelease: "true" + token: ${{ github.token }} + notes: | + Automatic pre-release built from `${{ github.sha }}` on `main`. + + Not intended for production use. Pin a `v*` release instead. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..83181f0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: "Release tag, for example v0.4.0" + required: true + type: string + +permissions: + contents: read + +concurrency: + group: release + cancel-in-progress: false + +jobs: + release: + runs-on: ubuntu-24.04 + permissions: + contents: write + id-token: write + attestations: write + steps: + - name: Validate the requested version + env: + VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "version must look like v1.2.3 or v1.2.3-rc.1; got $VERSION" >&2 + exit 1 + fi + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Refuse to reuse an existing tag + env: + GH_TOKEN: ${{ github.token }} + REPOSITORY: ${{ github.repository }} + VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + if gh api "repos/$REPOSITORY/git/ref/tags/$VERSION" >/dev/null 2>&1; then + echo "tag $VERSION already exists; immutable releases cannot reuse a tag" >&2 + exit 1 + fi + + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: .go-version + cache: true + + - name: Publish + uses: ./.github/actions/publish-release + with: + version: ${{ inputs.version }} + prerelease: "false" + token: ${{ github.token }} + notes: | + Release ${{ inputs.version }}, built from `${{ github.sha }}`. + + Pin this action with: + + ```yaml + uses: ${{ github.repository }}@${{ inputs.version }} + ``` diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index d47a6d3..628740d 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -23,6 +23,16 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: .go-version + cache: true + # Build locally so the smoke test exercises this commit rather than a + # binary downloaded from a release. + - name: Build server binaries + env: + VERSION: smoke-${{ github.sha }} + run: scripts/build-dist.sh - id: cache name: Start cache adapter uses: ./ diff --git a/.gitignore b/.gitignore index e623082..bf4070c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ coverage.out *.prof -dist/*.tmp .tools/ +dist/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e71e982..82367af 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,9 +5,10 @@ default, and compatible with Bazel's documented HTTP and gRPC remote-cache protocols. Before submitting a change, run every command in the development section of -the README. Changes to the Go server require rebuilding both checked-in -binaries with the pinned Go version. Changes to GitHub cache behavior should -also pass two separate smoke workflow runs: seed first, then restore-only. +the README. Built binaries are not committed; CI builds them on demand and the +release workflows publish them as release assets. Changes to GitHub cache +behavior should also pass two separate smoke workflow runs: seed first, then +restore-only. Never log `ACTIONS_RUNTIME_TOKEN`, signed Azure Blob URLs, or the shutdown token. New third-party GitHub Actions must be pinned to a complete commit SHA. diff --git a/README.md b/README.md index 3c39b3e..a49be79 100644 --- a/README.md +++ b/README.md @@ -361,14 +361,53 @@ go vet ./... go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./... go run golang.org/x/vuln/cmd/govulncheck@v1.6.0 ./... node --test action/*.test.js -VERSION=v0.3.2 scripts/build-dist.sh -git diff --exit-code -- dist +VERSION=dev scripts/build-dist.sh (cd dist && sha256sum --check SHA256SUMS) ``` Release binaries are built with `CGO_ENABLED=0`, `-trimpath`, and an empty Go -build ID, with VCS stamping disabled, for deterministic Linux amd64/arm64 output. CI rebuilds them and -requires a byte-for-byte match. +build ID, with VCS stamping disabled, for deterministic Linux amd64/arm64 +output. CI builds them twice and requires both builds to produce identical +checksums. + +`dist/` is not tracked in Git, and neither is any other build output. The action +resolves its server binary in two steps: + +1. If `dist/cache-server-linux-` exists in the checkout, it is used + directly. This is how local development, CI, and the smoke workflow exercise + the code under review rather than a published artifact. +2. Otherwise the binary is downloaded from the release the action itself was + pinned to, and its build provenance is verified with + `gh attestation verify` before it is allowed to run. + +Nothing in the repository records which release to use. `GITHUB_ACTION_REF` is +the ref from your `uses:` line, so `@v0.4.0` names its release directly, and a +commit pin is mapped back to the tag released from it. `GITHUB_ACTION_REPOSITORY` +supplies the repository, so a fork downloads its own releases instead of binaries +built from somebody else's source, with nothing to edit after forking. + +Integrity rests on +[artifact attestations](https://docs.github.com/en/actions/concepts/security/artifact-attestations): +the release workflows sign the binaries with `actions/attest-build-provenance`, +and the action refuses to run one that does not verify against the publishing +repository. Only someone who can add a workflow to that repository can produce a +passing attestation, so no checksum has to be committed alongside the action. + +## Releases + +Release tags point at the reviewed commit itself, so the tree a consumer checks +out is exactly the tree CI ran against. Enable +[immutable releases](https://docs.github.com/en/code-security/concepts/supply-chain-security/immutable-releases) +on the repository to lock those tags and assets after publication; the workflows +already draft, attach, then publish, which is the order that requires. + +| Workflow | Trigger | Tag | Marked | +| --- | --- | --- | --- | +| `Pre-release` | push to `main` | `pre-` | pre-release | +| `Release` | `workflow_dispatch` with a `version` input | the given `v*` tag | latest | + +Neither workflow commits anything. A release is a tag, a set of assets, and an +attestation; the default branch is never rewritten by CI. The smoke workflow has two modes. A default-branch push seeds a stable packed object. A separate `workflow_dispatch` restore run downloads the manifest and diff --git a/action/main.js b/action/main.js index 8e32d49..8c97631 100644 --- a/action/main.js +++ b/action/main.js @@ -16,6 +16,7 @@ const { saveState, setOutput, } = require("./lib"); +const { resolveServerBinary } = require("./release"); const sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)); @@ -57,11 +58,6 @@ async function main() { if (!architecture) { throw new Error(`unsupported Linux architecture: ${process.arch}`); } - const actionRoot = path.resolve(__dirname, ".."); - const binary = path.join(actionRoot, "dist", `cache-server-linux-${architecture}`); - if (!fs.existsSync(binary)) { - throw new Error(`packaged server binary is missing: ${binary}`); - } const writeEnabled = resolveWriteMode(input("write", "auto")); const failOpen = !parseBoolean(input("fail-on-cache-error", "false"), "fail-on-cache-error"); @@ -100,6 +96,19 @@ async function main() { const shutdownToken = crypto.randomBytes(32).toString("hex"); mask(shutdownToken); + const binary = await resolveServerBinary({ + actionRoot: path.resolve(__dirname, ".."), + architecture, + // Installing under a fixed name keeps every part of the spawned path a + // constant, so no release name can influence which program runs. + installPath: path.join(tempDir, "cache-server"), + repository: process.env.GITHUB_ACTION_REPOSITORY, + ref: process.env.GITHUB_ACTION_REF, + token: githubToken || process.env.GITHUB_TOKEN || "", + toolCacheRoot: path.resolve(process.env.RUNNER_TOOL_CACHE || process.env.RUNNER_TEMP || os.tmpdir()), + log: (message) => process.stdout.write(`${message}${os.EOL}`), + }); + const args = [ "--port", String(port), diff --git a/action/release.js b/action/release.js new file mode 100644 index 0000000..d253859 --- /dev/null +++ b/action/release.js @@ -0,0 +1,186 @@ +"use strict"; + +const fs = require("node:fs"); +const path = require("node:path"); +const { execFile } = require("node:child_process"); + +const ASSET_PREFIX = "cache-server-linux-"; +const USER_AGENT = "bazel-github-actions-cache-v2"; +const DOWNLOAD_TIMEOUT_MS = 120_000; +const VERIFY_TIMEOUT_MS = 60_000; +const API_TIMEOUT_MS = 30_000; +const REPOSITORY_PATTERN = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/; +const TAG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/; +const COMMIT_PATTERN = /^[0-9a-f]{40}$/; + +function assetName(architecture) { + return `${ASSET_PREFIX}${architecture}`; +} + +function releaseAssetUrl(repository, version, asset) { + return `https://github.com/${repository}/releases/download/${version}/${asset}`; +} + +async function download(url) { + const response = await fetch(url, { + headers: { "user-agent": USER_AGENT }, + signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS), + }); + if (!response.ok) { + throw new Error(`GET ${url} returned HTTP ${response.status}`); + } + // Release downloads redirect to object storage, and fetch follows that itself. + // The body is still unread here, so a redirect chain that ended up on plain + // HTTP is rejected before any of the binary travels over it. + if (!response.url.startsWith("https://")) { + throw new Error(`refusing to download ${url} over ${new URL(response.url).protocol}`); + } + return Buffer.from(await response.arrayBuffer()); +} + +async function githubJson(url, token) { + const headers = { "user-agent": USER_AGENT, accept: "application/vnd.github+json" }; + if (token) { + headers.authorization = `Bearer ${token}`; + } + const response = await fetch(url, { headers, signal: AbortSignal.timeout(API_TIMEOUT_MS) }); + if (!response.ok) { + throw new Error(`GET ${url} returned HTTP ${response.status}`); + } + return response.json(); +} + +// requireTag rejects anything that could not be a release tag. The value becomes +// both a URL segment and a path segment on the way to an executable, so it is +// checked here rather than at each use. +function requireTag(tag, problem) { + if (!TAG_PATTERN.test(String(tag ?? ""))) { + throw new Error(problem); + } + return String(tag); +} + +// releaseVersion works out which release publishes the binary for the running +// copy of the action. `uses: owner/repo@v1.2.3` names its release directly; a +// commit pin has to be mapped back to the tag that was released from it. +async function releaseVersion({ repository, ref, token }) { + if (COMMIT_PATTERN.test(String(ref ?? ""))) { + const refs = await githubJson( + `https://api.github.com/repos/${repository}/git/matching-refs/tags/`, + token, + ); + // Release tags are lightweight, so they point straight at the release commit. + const match = refs.find((entry) => entry.object?.type === "commit" && entry.object.sha === ref); + if (!match) { + throw new Error(`no release tag points at ${ref}; pin a released tag or commit`); + } + const tag = String(match.ref).replace(/^refs\/tags\//, ""); + return requireTag(tag, `${repository} has an unusable release tag at ${ref}`); + } + return requireTag( + ref, + "cannot tell which release to use; pin this action to a release tag or commit", + ); +} + +// verifyAttestation proves the binary came out of a workflow in the repository +// that published it. Only someone who can add a workflow there can produce a +// passing attestation, which is what makes a committed checksum unnecessary. +function verifyAttestation({ file, repository, token }) { + return new Promise((resolve, reject) => { + execFile( + "gh", + ["attestation", "verify", file, "--repo", repository], + { env: { ...process.env, GH_TOKEN: token }, timeout: VERIFY_TIMEOUT_MS }, + (error, _stdout, stderr) => { + if (!error) { + resolve(); + return; + } + if (error.code === "ENOENT") { + reject(new Error("the GitHub CLI is required to verify the server binary's provenance")); + return; + } + reject( + new Error( + `build provenance for ${path.basename(file)} could not be verified: ` + + `${String(stderr).trim() || error.message}`, + ), + ); + }, + ); + }); +} + +// install places a verified binary at a caller-chosen constant path. The value +// that reaches the process spawner is then built entirely from constants, so a +// release name cannot influence which program runs. +function install(source, destination) { + fs.rmSync(destination, { force: true }); + try { + fs.linkSync(source, destination); + } catch { + fs.copyFileSync(source, destination); + } + fs.chmodSync(destination, 0o700); + return destination; +} + +// resolveServerBinary returns a cache-server binary for this runner. A locally +// built dist/ always wins so that CI and the smoke workflow exercise the code +// under review rather than a published artifact. +async function resolveServerBinary({ + actionRoot, + architecture, + installPath, + repository, + ref, + token, + toolCacheRoot, + log, +}) { + const asset = assetName(architecture); + const localBinary = path.join(actionRoot, "dist", asset); + if (fs.existsSync(localBinary)) { + log(`using locally built dist/${asset}`); + return localBinary; + } + // The repository comes from whichever copy of the action is running, so a fork + // downloads its own releases rather than binaries built from other sources. + if (!REPOSITORY_PATTERN.test(String(repository ?? ""))) { + throw new Error( + "cannot tell which repository published this action; run scripts/build-dist.sh to use a local build", + ); + } + + const version = await releaseVersion({ repository, ref, token }); + const cached = path.join(toolCacheRoot, "bazel-gha-cache-server", version, architecture, asset); + if (fs.existsSync(cached)) { + log(`using cached ${asset} from ${version}`); + return install(cached, installPath); + } + + const url = releaseAssetUrl(repository, version, asset); + log(`downloading ${url}`); + const bytes = await download(url); + fs.mkdirSync(path.dirname(cached), { recursive: true }); + const spool = `${cached}.${process.pid}.part`; + fs.writeFileSync(spool, bytes, { mode: 0o700 }); + try { + await verifyAttestation({ file: spool, repository, token }); + } catch (error) { + fs.rmSync(spool, { force: true }); + throw error; + } + log(`verified the build provenance of ${asset} from ${version}`); + fs.renameSync(spool, cached); + return install(cached, installPath); +} + +module.exports = { + assetName, + download, + releaseAssetUrl, + releaseVersion, + resolveServerBinary, +}; diff --git a/action/release.test.js b/action/release.test.js new file mode 100644 index 0000000..da33009 --- /dev/null +++ b/action/release.test.js @@ -0,0 +1,209 @@ +"use strict"; + +const assert = require("node:assert"); +const fs = require("node:fs"); +const http = require("node:http"); +const os = require("node:os"); +const path = require("node:path"); +const { test } = require("node:test"); + +const { + assetName, + download, + releaseAssetUrl, + releaseVersion, + resolveServerBinary, +} = require("./release"); + +const REPOSITORY = "cre4ture/bazel-github-actions-cache-v2"; +const COMMIT = "b".repeat(40); +const realFetch = globalThis.fetch.bind(globalThis); + +function workspace(t) { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "release-test-")); + t.after(() => fs.rmSync(root, { recursive: true, force: true })); + return root; +} + +function resolve(overrides) { + return resolveServerBinary({ + architecture: "amd64", + repository: REPOSITORY, + ref: "v1.2.3", + token: "", + log: () => {}, + ...overrides, + }); +} + +function stubFetch(t, handler) { + globalThis.fetch = handler; + t.after(() => { + globalThis.fetch = realFetch; + }); +} + +function jsonResponse(body) { + return Promise.resolve({ ok: true, url: "https://api.github.com/", json: async () => body }); +} + +async function localServer(t, handler) { + const server = http.createServer(handler); + await new Promise((ready) => server.listen(0, "127.0.0.1", ready)); + t.after(() => server.close()); + return `127.0.0.1:${server.address().port}`; +} + +test("release assets are addressed by tag, not by latest", () => { + assert.strictEqual( + releaseAssetUrl(REPOSITORY, "v1.2.3", assetName("arm64")), + "https://github.com/cre4ture/bazel-github-actions-cache-v2/releases/download/v1.2.3/cache-server-linux-arm64", + ); +}); + +test("a tag ref names its own release", async () => { + assert.strictEqual(await releaseVersion({ repository: REPOSITORY, ref: "v1.2.3" }), "v1.2.3"); +}); + +test("a commit pin resolves to the tag released from it", async (t) => { + stubFetch(t, (url) => { + assert.match(String(url), /git\/matching-refs\/tags\//); + return jsonResponse([ + { ref: "refs/tags/v1.0.0", object: { type: "commit", sha: "a".repeat(40) } }, + { ref: "refs/tags/v1.2.3", object: { type: "commit", sha: COMMIT } }, + ]); + }); + assert.strictEqual(await releaseVersion({ repository: REPOSITORY, ref: COMMIT }), "v1.2.3"); +}); + +test("a commit that was never released is reported as such", async (t) => { + stubFetch(t, () => jsonResponse([])); + await assert.rejects( + releaseVersion({ repository: REPOSITORY, ref: COMMIT }), + /no release tag points at/, + ); +}); + +// A tag name reaches both a download URL and the path of the binary that gets +// executed, so a hostile one must never be taken at face value. +test("a tag name that could escape its directory is rejected", async (t) => { + for (const ref of [ + "refs/tags/../../../../tmp/evil", + "refs/tags/v1.2.3/../../..", + "refs/tags/v1;rm -rf /", + "refs/tags/", + ]) { + stubFetch(t, () => jsonResponse([{ ref, object: { type: "commit", sha: COMMIT } }])); + await assert.rejects( + releaseVersion({ repository: REPOSITORY, ref: COMMIT }), + /unusable release tag/, + ); + } +}); + +test("a ref that names no release at all is rejected", async () => { + for (const ref of [undefined, "", "refs/heads/main", "feature branch"]) { + await assert.rejects( + releaseVersion({ repository: REPOSITORY, ref }), + /pin this action to a release tag or commit/, + ); + } +}); + +test("a locally built binary is preferred over any published release", async (t) => { + const root = workspace(t); + const actionRoot = path.join(root, "checkout"); + const local = path.join(actionRoot, "dist", assetName("amd64")); + fs.mkdirSync(path.dirname(local), { recursive: true }); + fs.writeFileSync(local, "locally built"); + + assert.strictEqual( + await resolve({ actionRoot, toolCacheRoot: path.join(root, "tools") }), + local, + ); +}); + +test("an action running from an unknown repository will not guess where to download", async (t) => { + const root = workspace(t); + await assert.rejects( + resolve({ + actionRoot: path.join(root, "checkout"), + repository: undefined, + toolCacheRoot: path.join(root, "tools"), + }), + /cannot tell which repository/, + ); +}); + +test("an already verified binary is installed at the fixed path that gets executed", async (t) => { + const root = workspace(t); + const toolCacheRoot = path.join(root, "tools"); + const version = "v1.2.3"; + const cached = path.join( + toolCacheRoot, + "bazel-gha-cache-server", + version, + "amd64", + assetName("amd64"), + ); + fs.mkdirSync(path.dirname(cached), { recursive: true }); + fs.writeFileSync(cached, "previously verified"); + const installPath = path.join(root, "cache-server"); + + const resolved = await resolve({ + actionRoot: path.join(root, "checkout"), + installPath, + toolCacheRoot, + }); + assert.strictEqual(resolved, installPath); + assert.strictEqual(fs.readFileSync(resolved, "utf8"), "previously verified"); + // The executed path must carry no trace of the release it came from. + assert.ok(!resolved.includes(version), `${resolved} still names the release`); +}); + +test("a download that lands on plain HTTP is refused before the body is read", async (t) => { + let served = false; + const address = await localServer(t, (_, response) => { + served = true; + response.writeHead(200).end("a binary that must never be trusted"); + }); + + await assert.rejects( + download(`http://${address}/${assetName("amd64")}`), + /refusing to download/, + ); + assert.ok(served, "the endpoint should have been reached and then rejected"); +}); + +test("a binary whose provenance cannot be verified is discarded", async (t) => { + const root = workspace(t); + const toolCacheRoot = path.join(root, "tools"); + const address = await localServer(t, (_, response) => { + response.writeHead(200).end("an unattested binary"); + }); + // Serve the asset locally while reporting the HTTPS origin the download + // requires, so that verification rather than transport is what fails. + stubFetch(t, async (url) => { + const served = await realFetch(String(url).replace(/^https:\/\/github\.com/, `http://${address}`)); + return { ok: true, url: "https://github.com/", arrayBuffer: () => served.arrayBuffer() }; + }); + // Hide the GitHub CLI so verification fails locally instead of reaching out. + const realPath = process.env.PATH; + process.env.PATH = path.join(root, "empty"); + t.after(() => { + process.env.PATH = realPath; + }); + + await assert.rejects( + resolve({ + actionRoot: path.join(root, "checkout"), + installPath: path.join(root, "cache-server"), + toolCacheRoot, + }), + /provenance|GitHub CLI/, + ); + const cacheDir = path.join(toolCacheRoot, "bazel-gha-cache-server", "v1.2.3", "amd64"); + const leftovers = fs.existsSync(cacheDir) ? fs.readdirSync(cacheDir) : []; + assert.deepStrictEqual(leftovers, [], "an unverified download must not be left behind"); + assert.ok(!fs.existsSync(path.join(root, "cache-server")), "nothing must be installed"); +}); diff --git a/dist/SHA256SUMS b/dist/SHA256SUMS deleted file mode 100644 index 187e7e5..0000000 --- a/dist/SHA256SUMS +++ /dev/null @@ -1,2 +0,0 @@ -f78d1caf02f9211eaf6e680e9dd5692b1a03355365505f617a5ad3fd254af0f0 cache-server-linux-amd64 -f6881c1ecefc1aa070bfe62ee567c45508e187da5af09fb1529bb00709a7ba30 cache-server-linux-arm64 diff --git a/dist/cache-server-linux-amd64 b/dist/cache-server-linux-amd64 deleted file mode 100755 index bbbdec4d49603471285996d745c4af6788d314f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9744510 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