Skip to content

Conversation

@leodido
Copy link
Contributor

@leodido leodido commented Dec 3, 2025

Summary

Fixes cache inconsistency when a package is downloaded but one of its dependencies fails to download (e.g., network error, SLSA verification failure).

Part of https://linear.app/ona-team/issue/CLC-2133/rollout-on-main

Problem

When package A downloads successfully but its dependency B fails:

  1. A is in local cache, B is not
  2. A.build() finds A in cache → returns early
  3. A.buildDependencies() is never called
  4. B is never built
  5. Build fails with PkgNotBuiltErr{B} and cannot recover

Solution

After the download phase, validate that all cached packages have their required dependencies available. If a dependency is missing and won't be built, remove the package from cache and mark it for rebuild.

Implementation

New function validateDependenciesAvailable:

  • Go/Yarn packages: checks all transitive dependencies
  • Generic/Docker packages: checks only direct dependencies
  • Ephemeral dependencies are skipped (always rebuilt)

Dependency is considered available if:

  • In local cache, OR
  • Will be built (PackageNotBuiltYet), OR
  • Will be downloaded (PackageInRemoteCache)

Testing

Unit tests cover:

  • No dependencies
  • All deps in cache
  • Deps marked for build
  • Deps in remote cache
  • Missing deps (unknown status)
  • Ephemeral deps (skipped)
  • Go/Yarn transitive deps
  • Docker direct deps only
=== RUN   TestValidateDependenciesAvailable
--- PASS: TestValidateDependenciesAvailable (0.00s)
=== RUN   TestValidateDependenciesAvailable_YarnPackage
--- PASS: TestValidateDependenciesAvailable_YarnPackage (0.00s)

Performance Impact

Negligible. The validation:

  • Reuses GetTransitiveDependencies() (already computed during download planning)
  • Only performs filesystem stat calls via Location()
  • For 50 packages × 10 deps = ~500 stat calls ≈ <50ms

Affects Both SLSA and Non-SLSA Builds

The bug can occur in both modes due to network errors during download.

Co-authored-by: Ona no-reply@ona.com

@leodido leodido self-assigned this Dec 3, 2025
leodido and others added 3 commits December 4, 2025 13:22
When a package is downloaded but one of its dependencies fails to
download (e.g., network error, SLSA verification failure), the cached
package becomes unusable because its dependencies are missing.

This causes build failures that cannot recover because:
1. Package A is in cache, so A.build() returns early
2. A.buildDependencies() is never called
3. Missing dependency B is never built
4. Build fails with PkgNotBuiltErr{B}

Fix: After the download phase, validate that all cached packages have
their required dependencies available. If a dependency is missing and
won't be built, remove the package from cache and mark it for rebuild.

The validation respects package types:
- Go/Yarn packages: check all transitive dependencies
- Generic/Docker packages: check only direct dependencies
- Ephemeral dependencies are skipped (always rebuilt)

A dependency is considered available if:
- It's in the local cache, OR
- It will be built (PackageNotBuiltYet), OR
- It will be downloaded (PackageInRemoteCache)

Co-authored-by: Ona <no-reply@ona.com>
Reduce the expected speedup from 3x to 2.5x for 50+ packages to
account for CI environment variability. The test was flaky because
CI runners have variable performance characteristics.

Co-authored-by: Ona <no-reply@ona.com>
Tests the scenario where package A downloads successfully but its
dependency B fails to download. Verifies that:
1. A is invalidated due to missing dependency B
2. Both A and B are rebuilt locally
3. Build succeeds with all packages in local cache

Uses a mock remote cache that simulates download failures for
specific packages.

Co-authored-by: Ona <no-reply@ona.com>
@leodido leodido force-pushed the ld/validate-deps-after-download branch from 1ba8d13 to 3f10a7e Compare December 4, 2025 13:23
@leodido leodido merged commit 8c76808 into main Dec 5, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants