How can an agent resolve this problem? How should CI caches avoid restoring incompatible dependencies across runtime versions?
## Question
How should CI caches avoid restoring incompatible dependencies across runtime versions?
## Why this matters
Recurring public developer task for Common developer stacks.
## Environment / product
Common developer stacks
## What needs to be determined
Current researched guidance, applicability, limitations, and primary sources for this question.
Researched guidance is proposed, not an execution report.
Problem details
- Observed symptom
- How should CI caches avoid restoring incompatible dependencies across runtime versions?
- Context
- Recurring public developer task; researched guidance is proposed, not an execution report.
- Environment
- Unknown · not established
- Symptom signature
- Literal source
- Not supplied
- Expected behavior
- Not supplied
Known approaches
solution · Revision 1
Researched guidance: How should CI caches avoid restoring incompatible dependencies across runtime versions?
## Summary
Prevent incompatible dependency reuse by separating download-store caches from installed or compiled artifacts. Key every environment-dependent cache with the lockfile plus all dimensions that change the cached bytes or their interpretation; use broad fallback keys only within that same compatibility boundary. Prefer official setup actions or package-manager stores and still run a deterministic install after restore.
## Candidate action
First classify each cache path. For package-manager download/HTTP stores, prefer the language vendor's setup action or native cache and key it from every governing dependency file; GitHub setup-node explicitly caches the global package-manager store rather than node_modules and supports cache-dependency-path, while setup-python uses dependency-file hashes. For installed dependency trees, virtual environments, native wheels, compiler outputs, or other executable artifacts, use a versioned key such as <schema>-<OS>-<architecture>-<runtime-and-ABI>-<package-manager-and-cache-format>-<lockfile/config-digest>. Include runtime and architecture when they can change binary compatibility; pin the matrix runtime and runner image rather than using an implicit latest. Keep restore/fallback prefixes inside the same OS/architecture/runtime/manager boundary, or omit them for executable artifacts. After any restore, run the package manager's clean or frozen/locked install and validate the resolved graph; a cache hit is only a speed optimization, not proof that the installed tree is compatible. Bump the schema component when the cached path, compression/archive format, toolchain, or key logic changes. In GitLab, use cache:key:files for lockfiles and prefix for job separation, but add explicit environment dimensions when the image/runtime changes them.
## Applicability
- CI matrices spanning multiple operating systems, CPU architectures, language runtimes, toolchains, or package-manager versions.
- Dependency download caches such as npm/Yarn/pnpm, pip, Maven/Gradle, Go modules, and similar stores.
- Installed dependency trees, virtual environments, native extensions, compiled outputs, and build caches where runtime or ABI changes can invalidate bytes.
- GitHub Actions and GitLab CI; adapt the key syntax to other CI providers while preserving the compatibility dimensions.
## Key findings
- GitHub's official reference recommends keying dependency caches from a runner OS component and a hash of the dependency lockfile; it states that cache matching also considers cache version, and that restore keys are prefix fallbacks returning the newest matching cache. (S1)
- The official actions/cache strategy guide recommends combining multiple factors such as operating system and lockfile, while the setup-node documentation says its cache targets the global package-manager cache rather than node_modules and can be reused between Node.js versions. (S2, S3)
- GitLab's official documentation provides cache:key:files for lockfile-content keys and prefix for job-specific separation, but its examples do not include runtime versions; therefore runtime/image scoping must be added when the cached path is environment-dependent. (S4)
- pip's official documentation says cache structure is an implementation detail that may change between pip versions and warns that a cached pure-Python wheel from an environment lacking an optional C extension can be reused later when compiling the extension would have been possible; it recommends a source-distribution install when that distinction matters. (S5)
## Known limitations
- GitHub's dependency-caching reference explicitly demonstrates runner OS plus lockfile hashing, but does not prescribe CPU-architecture, interpreter/runtime-version, or package-manager-version components; those dimensions are an engineering requirement when they affect cached content, not a universal platform rule.
- setup-node says its global package-manager cache can be reused between Node.js versions; that does not establish that node_modules, native addons, or build outputs are safe to share across Node versions.
- GitLab's official examples key from lockfiles and show runtime images, but do not include runtime versions in those example keys; a project must add them when the selected cache path is runtime-sensitive.
- pip documents that cache internals can change between pip versions and gives an optional-C-extension case where a cached pure-Python wheel can suppress a later rebuild; exact cross-platform and cross-architecture reuse rules are not specified on that page.
- Documentation supports proposed guidance only; no target repository, CI runner, cache backend, dependency installation, or compatibility test was executed.
## Negative results
- Do not use only a lockfile hash for a cache containing native or runtime-specific installed artifacts when the same lockfile can be built under multiple environments.
- Do not use a broad restore prefix that crosses operating systems, architectures, runtime/ABI families, package-manager generations, or cache schemas for executable artifacts.
- Do not assume a setup action's global download-store cache has the same compatibility behavior as caching node_modules, a virtualenv, vendor/, or compiled build output.
- A cache hit or restored partial cache is not an execution proof; the install and validation still need to run.
## Evidence boundary
- basis=researched_guidance; executed=false; independent_reproduction=false
- This result is based on official GitHub Actions dependency-caching documentation, the official actions/cache and actions/setup-node repositories, official GitLab CI/CD caching documentation, and pip's official caching documentation read on 2026-09-21; no CI workflow or cache was executed.
- The sources establish lockfile/OS keying, restore-prefix behavior, setup-action cache paths, and pip cache caveats; they do not prove compatibility for an unspecified repository, runner image, dependency graph, architecture, or cache backend.
## What remains unknown
- The target CI provider, operating-system and architecture matrix, runner image, language/runtime versions, package-manager versions, and exact cache paths are unspecified.
- It is unknown whether the target cache stores download artifacts, installed trees, native wheels/extensions, compiler outputs, or mixed content; this determines which dimensions must be keyed.
- It is unknown which lockfiles, toolchain files, registry configuration, patches, build flags, and environment variables can alter the resolved or compiled bytes.
- It is unknown whether current fallback keys cross compatibility boundaries, whether installs are clean/frozen after restore, and whether cache contents are validated against the intended runtime and lockfile.
- No execution evidence establishes cross-runtime, cross-architecture, cross-manager, or cache-corruption behavior for the target workload.
## Evidence
- basis: researched_guidance
- executed: false
- independent reproduction: false
## Sources
- [S1] Dependency caching reference - GitHub Docs — https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching (official_documentation; accessed 2026-09-21)
- [S2] actions/cache caching strategies — https://github.com/actions/cache/blob/main/caching-strategies.md (official_repository; accessed 2026-09-21)
- [S3] setup-node advanced usage: caching packages data — https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md (official_repository; accessed 2026-09-21)
- [S4] Caching in GitLab CI/CD — https://docs.gitlab.com/ci/caching/ (official_documentation; accessed 2026-09-21)
- [S5] Caching - pip documentation — https://pip.pypa.io/en/stable/topics/caching/ (official_documentation; accessed 2026-09-21)
- Problem id
- 431a8480-f0de-44f1-9d54-c3bfd5055e3d
- Proposed action
- First classify each cache path. For package-manager download/HTTP stores, prefer the language vendor's setup action or native cache and key it from every governing dependency file; GitHub setup-node explicitly caches the global package-manager store rather than node_modules and supports cache-dependency-path, while setup-python uses dependency-file hashes. For installed dependency trees, virtual environments, native wheels, compiler outputs, or other executable artifacts, use a versioned key such as <schema>-<OS>-<architecture>-<runtime-and-ABI>-<package-manager-and-cache-format>-<lockfile/config-digest>. Include runtime and architecture when they can change binary compatibility; pin the matrix runtime and runner image rather than using an implicit latest. Keep restore/fallback prefixes inside the same OS/architecture/runtime/manager boundary, or omit them for executable artifacts. After any restore, run the package manager's clean or frozen/locked install and validate the resolved graph; a cache hit is only a speed optimization, not proof that the installed tree is compatible. Bump the schema component when the cached path, compression/archive format, toolchain, or key logic changes. In GitLab, use cache:key:files for lockfiles and prefix for job separation, but add explicit environment dimensions when the image/runtime changes them.
- Applicability
- State
- partial
- Text
- CI matrices spanning multiple operating systems, CPU architectures, language runtimes, toolchains, or package-manager versions. Dependency download caches such as npm/Yarn/pnpm, pip, Maven/Gradle, Go modules, and similar stores. Installed dependency trees, virtual environments, native extensions, compiled outputs, and build caches where runtime or ABI changes can invalidate bytes. GitHub Actions and GitLab CI; adapt the key syntax to other CI providers while preserving the compatibility dimensions.
- Limitations
- State
- partial
- Text
- GitHub's dependency-caching reference explicitly demonstrates runner OS plus lockfile hashing, but does not prescribe CPU-architecture, interpreter/runtime-version, or package-manager-version components; those dimensions are an engineering requirement when they affect cached content, not a universal platform rule. setup-node says its global package-manager cache can be reused between Node.js versions; that does not establish that node_modules, native addons, or build outputs are safe to share across Node versions. GitLab's official examples key from lockfiles and show runtime images, but do not include runtime versions in those example keys; a project must add them when the selected cache path is runtime-sensitive. pip documents that cache internals can change between pip versions and gives an optional-C-extension case where a cached pure-Python wheel can suppress a later rebuild; exact cross-platform and cross-architecture reuse rules are not specified on that page. Documentation supports proposed guidance only; no target repository, CI runner, cache backend, dependency installation, or compatibility test was executed.
- Success criteria
- Not supplied
- Risk notes
- Not supplied
- Lifecycle
- active
- Pack
- Schema version
- 1
- Candidate action
- First classify each cache path. For package-manager download/HTTP stores, prefer the language vendor's setup action or native cache and key it from every governing dependency file; GitHub setup-node explicitly caches the global package-manager store rather than node_modules and supports cache-dependency-path, while setup-python uses dependency-file hashes. For installed dependency trees, virtual environments, native wheels, compiler outputs, or other executable artifacts, use a versioned key such as <schema>-<OS>-<architecture>-<runtime-and-ABI>-<package-manager-and-cache-format>-<lockfile/config-digest>. Include runtime and architecture when they can change binary compatibility; pin the matrix runtime and runner image rather than using an implicit latest. Keep restore/fallback prefixes inside the same OS/architecture/runtime/manager boundary, or omit them for executable artifacts. After any restore, run the package manager's clean or frozen/locked install and validate the resolved graph; a cache hit is only a speed optimization, not proof that the installed tree is compatible. Bump the schema component when the cached path, compression/archive format, toolchain, or key logic changes. In GitLab, use cache:key:files for lockfiles and prefix for job separation, but add explicit environment dimensions when the image/runtime changes them.
- Applicability
- CI matrices spanning multiple operating systems, CPU architectures, language runtimes, toolchains, or package-manager versions.
Dependency download caches such as npm/Yarn/pnpm, pip, Maven/Gradle, Go modules, and similar stores.
Installed dependency trees, virtual environments, native extensions, compiled outputs, and build caches where runtime or ABI changes can invalidate bytes.
GitHub Actions and GitLab CI; adapt the key syntax to other CI providers while preserving the compatibility dimensions. - Limitations
- GitHub's dependency-caching reference explicitly demonstrates runner OS plus lockfile hashing, but does not prescribe CPU-architecture, interpreter/runtime-version, or package-manager-version components; those dimensions are an engineering requirement when they affect cached content, not a universal platform rule.
setup-node says its global package-manager cache can be reused between Node.js versions; that does not establish that node_modules, native addons, or build outputs are safe to share across Node versions.
GitLab's official examples key from lockfiles and show runtime images, but do not include runtime versions in those example keys; a project must add them when the selected cache path is runtime-sensitive.
pip documents that cache internals can change between pip versions and gives an optional-C-extension case where a cached pure-Python wheel can suppress a later rebuild; exact cross-platform and cross-architecture reuse rules are not specified on that page.
Documentation supports proposed guidance only; no target repository, CI runner, cache backend, dependency installation, or compatibility test was executed. - Evidence boundary
- basis=researched_guidance; executed=false; independent_reproduction=false
This result is based on official GitHub Actions dependency-caching documentation, the official actions/cache and actions/setup-node repositories, official GitLab CI/CD caching documentation, and pip's official caching documentation read on 2026-09-21; no CI workflow or cache was executed.
The sources establish lockfile/OS keying, restore-prefix behavior, setup-action cache paths, and pip cache caveats; they do not prove compatibility for an unspecified repository, runner image, dependency graph, architecture, or cache backend. - What remains unknown
- The target CI provider, operating-system and architecture matrix, runner image, language/runtime versions, package-manager versions, and exact cache paths are unspecified.
It is unknown whether the target cache stores download artifacts, installed trees, native wheels/extensions, compiler outputs, or mixed content; this determines which dimensions must be keyed.
It is unknown which lockfiles, toolchain files, registry configuration, patches, build flags, and environment variables can alter the resolved or compiled bytes.
It is unknown whether current fallback keys cross compatibility boundaries, whether installs are clean/frozen after restore, and whether cache contents are validated against the intended runtime and lockfile.
No execution evidence establishes cross-runtime, cross-architecture, cross-manager, or cache-corruption behavior for the target workload. - Summary
- Prevent incompatible dependency reuse by separating download-store caches from installed or compiled artifacts. Key every environment-dependent cache with the lockfile plus all dimensions that change the cached bytes or their interpretation; use broad fallback keys only within that same compatibility boundary. Prefer official setup actions or package-manager stores and still run a deterministic install after restore.
- Negative results
- Do not use only a lockfile hash for a cache containing native or runtime-specific installed artifacts when the same lockfile can be built under multiple environments.
Do not use a broad restore prefix that crosses operating systems, architectures, runtime/ABI families, package-manager generations, or cache schemas for executable artifacts.
Do not assume a setup action's global download-store cache has the same compatibility behavior as caching node_modules, a virtualenv, vendor/, or compiled build output.
A cache hit or restored partial cache is not an execution proof; the install and validation still need to run. - Key findings
- Text
- GitHub's official reference recommends keying dependency caches from a runner OS component and a hash of the dependency lockfile; it states that cache matching also considers cache version, and that restore keys are prefix fallbacks returning the newest matching cache.
- Source ids
- S1
- Text
- The official actions/cache strategy guide recommends combining multiple factors such as operating system and lockfile, while the setup-node documentation says its cache targets the global package-manager cache rather than node_modules and can be reused between Node.js versions.
- Source ids
- S2
S3
- Text
- GitLab's official documentation provides cache:key:files for lockfile-content keys and prefix for job-specific separation, but its examples do not include runtime versions; therefore runtime/image scoping must be added when the cached path is environment-dependent.
- Source ids
- S4
- Text
- pip's official documentation says cache structure is an implementation detail that may change between pip versions and warns that a cached pure-Python wheel from an environment lacking an optional C extension can be reused later when compiling the extension would have been possible; it recommends a source-distribution install when that distinction matters.
- Source ids
- S5
- Research sources
- Id
- S1
- Title
- Dependency caching reference - GitHub Docs
- Url
- https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching
- Source class
- official_documentation
- Accessed at
- 2026-09-21
- Id
- S2
- Title
- actions/cache caching strategies
- Url
- https://github.com/actions/cache/blob/main/caching-strategies.md
- Source class
- official_repository
- Accessed at
- 2026-09-21
- Id
- S3
- Title
- setup-node advanced usage: caching packages data
- Url
- https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md
- Source class
- official_repository
- Accessed at
- 2026-09-21
- Id
- S4
- Title
- Caching in GitLab CI/CD
- Url
- https://docs.gitlab.com/ci/caching/
- Source class
- official_documentation
- Accessed at
- 2026-09-21
- Id
- S5
- Title
- Caching - pip documentation
- Url
- https://pip.pypa.io/en/stable/topics/caching/
- Source class
- official_documentation
- Accessed at
- 2026-09-21
solution · Revision 1
[Candidate / unverified] Solution for 431a8480-f0de-44f1-9d54-c3bfd5055e3d: Classify each cached path as download store vs installed/native artifacts. Key e
## Support semantics
This is a **candidate / unverified** Solution from the KFA Solution Factory Tier-2 gate. It is source-grounded research material, not an Outcome, and does **not** claim independent reproduction or confirmed field success.
## Cause
Platform cache matching uses key prefixes and restore-keys; official examples emphasize OS plus lockfile but executable artifacts also depend on runtime ABI and tool versions unless operators add those components.
## Steps
1. Inventory cached paths (npm store, pip cache, node_modules, venv, build output).
2. Build primary cache keys from lockfiles and every dimension that changes cached bytes.
3. Limit restore-keys to prefixes within the same OS/arch/runtime/manager family.
4. Pin matrix Node/Python/etc. versions explicitly; bump key schema when cache layout changes.
5. Run locked install after restore; fail job if resolver reports mismatch.
## Expected result
Jobs only reuse caches compatible with the current runner environment; incompatible graphs are rebuilt deterministically after restore.
## Misleading approaches
- Lockfile-only keys for node_modules or wheels with native extensions.
- Broad restore-keys that match caches from other OS or runtime matrix legs.
- Skipping install after a cache hit.
## Limitations
- GitHub's reference examples do not mandate runtime-version components for all cache types; teams must add them when caching installed/native artifacts.
- setup-node documents global package-manager cache reuse across Node versions, which does not imply node_modules safety across versions.
- pip cache structure may change between pip versions.
- Not executed on a target repository.
## Unknowns
- Target CI provider, matrix, and exact cached directories.
- Whether current workflows cross compatibility boundaries in restore-keys.
## Evidence claims
- (documented_platform_behavior) GitHub Actions restore-keys perform prefix fallback to the newest partial match, which can restore an older cache entry if keys omit environment dimensions. — https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching
- (documented_platform_behavior) actions/setup-node caches the global package-manager store, not node_modules, and documents reuse between Node.js versions for that store. — https://raw.githubusercontent.com/actions/setup-node/main/docs/advanced-usage.md
- (documented_platform_behavior) pip warns that wheel cache behavior is an implementation detail that may change between pip versions and can reuse wheels that suppress later native builds. — https://pip.pypa.io/en/stable/topics/caching/
- Problem id
- 431a8480-f0de-44f1-9d54-c3bfd5055e3d
- Proposed action
- Classify each cached path as download store vs installed/native artifacts. Key environment-sensitive caches with lockfile digest plus OS, architecture, runtime version, package-manager version, and a schema version; keep restore-key prefixes inside the same boundary. Prefer official setup-* actions for global package-manager stores (not node_modules). After restore, run frozen/clean install and validate the resolved graph; treat cache hit as optimization only.
- Applicability
- State
- partial
- Text
- support: candidate_unverified (not an Outcome; no reproduction claim); GitHub Actions and GitLab CI jobs with dependency caches across matrices of OS, architecture, language runtime, or package-manager versions.; fix_status: PARTIAL
- Limitations
- State
- partial
- Text
- GitHub's reference examples do not mandate runtime-version components for all cache types; teams must add them when caching installed/native artifacts. setup-node documents global package-manager cache reuse across Node versions, which does not imply node_modules safety across versions. pip cache structure may change between pip versions. Not executed on a target repository.
- Success criteria
- Not supplied
- Risk notes
- Not supplied
- Lifecycle
- active
Page 1 · 2 children total
Sources and related records
No source relations recorded.