perf(docker): preserve warm sandbox build cache - #6019
Conversation
Move runtime defaults after build-time layers so identical sandbox rebuilds can reuse Docker cache. Keep stock build IDs stable unless custom Dockerfiles consume the build ID. Signed-off-by: Angel Mata <amata@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe ChangesDockerfile ENV deferral and conditional BUILD_ID patching
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in the Show a code coverage summary of the most covered files.
TypeScript / code-coverage/cliThe overall coverage in the Show a code coverage summary of the most covered files.
Updated |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
Vitest E2E Scenario RecommendationRequired Vitest E2E scenarios: Dispatch required Vitest E2E scenarios:
Full Vitest E2E advisor summaryVitest E2E Scenario AdvisorBase: Required Vitest E2E scenarios
Optional Vitest E2E scenarios
Relevant changed files
|
PR Review Advisor — Changes requestedMerge posture: Do not merge yet Action checklist
Findings index
🚨 Required before mergeAddress these before merging unless a maintainer explicitly overrides the advisor with rationale.
|
PR Review Advisor (Nemotron Ultra) — Changes requestedMerge posture: Do not merge yet Action checklist
Findings index
🚨 Required before mergeAddress these before merging unless a maintainer explicitly overrides the advisor with rationale.
|
Record cold versus warm sandbox build evidence and clarify the OpenClaw config generator ARG contract. Cover custom Dockerfile build-id consumption patterns called out by PR Advisor. Signed-off-by: Angel Mata <amata@nvidia.com>
|
Addressed the PR Advisor items in
Validation rerun:
|
E2E Target RecommendationRequired E2E targets: Dispatch required E2E targets:
Full E2E target advisor summaryE2E Target AdvisorBase: Required E2E targets
Optional E2E targets
Relevant changed files
|
|
Superseded by #6034, a signed same-repo salvage that preserves Angel Mata's authorship and timing evidence. The replacement narrows the change to the verified cache lever (stable stock NEMOCLAW_BUILD_ID), adds byte-identical OpenClaw/Hermes build-context regressions, and drops the late-ENV relocation after a BuildKit control showed changed ARG values still invalidate following RUN layers. |
<!-- markdownlint-disable MD041 --> ## Summary Preserve Docker layer reuse for identical warm sandbox builds by leaving `NEMOCLAW_BUILD_ID` stable in stock OpenClaw and Hermes Dockerfiles. Custom `--from` Dockerfiles and managed agents that consume the compatibility argument retain the historical sanitized per-run rewrite. This is a signed, narrowed replacement for #6019. It intentionally drops that PR's late-`ENV` relocation because an empirical BuildKit control proved that changing any in-scope `ARG` still invalidates following `RUN` layers even when the instruction does not mention the argument. ## Related Issue Fixes #4682 ## Changes - Select build-ID policy from explicit provenance: preserve only the known-safe managed OpenClaw/Hermes Dockerfiles; custom `--from` and other managed agents retain unconditional rewriting. - Keep the stock Dockerfile's `ARG NEMOCLAW_BUILD_ID=default`, with an explicit comment that gateway tokens are generated at container startup and are not baked into image layers. - Add focused behavioral coverage for indirect custom consumers, newline sanitization, managed provenance selection, and OpenClaw/Hermes byte identity; move cache coverage out of the large shared patcher test. - Require patched stock Dockerfiles to remain byte-identical when only the per-run build ID changes. - Preserve the contributor’s cold/warm evidence: OpenClaw `20.9s` to `0.1s`; Hermes `21.5s` to `0.4s`, with real rebuilt-versus-`CACHED` BuildKit excerpts, the measurement boundary, and the ARG-scope caveat recorded in the test fixture. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — internal build-context/cache behavior; no user command, configuration, or support contract changes - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — the salvage preserves the existing ARG/ENV and runtime-token boundaries; custom values still pass through `sanitizeDockerArg`; no credential material is added to layers - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Git hooks passed during commit and push, or `npx prek run --from-ref main --to-ref HEAD` passes - [x] Targeted tests pass for changed behavior - [ ] Full `npm test` passes (broad runtime changes only) - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) Evidence: 37 focused patch/policy assertions; the normal hook passed 8,330 tests (8,299 passed, 31 skipped) plus source-shape, size, security, lint, DCO, and commitlint gates; CLI pre-push typecheck passed. Real BuildKit controls identified and then cached OpenClaw’s 3.7s plugin + 10.9s layout layers and Hermes’s 9.0s config + 4.8s layout layers. Parent timing record: #3776 (comment). Commits `22c39549bbb6d2aa1796647ecc26973293252545` and `c740d4cc3b63d541e7881e3d8206dc31d581501b` are GitHub Verified. --- Co-authored-by: Angel Mata <amata@nvidia.com> Signed-off-by: Angel Mata <amata@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved Docker build handling for onboarded environments, with smarter per-run build ID behavior for managed and custom Dockerfiles. * Added support for preserving stable build IDs in selected managed-agent flows to reduce unnecessary rebuilds. * **Bug Fixes** * Fixed cases where build ID changes could trigger avoidable cache misses during repeated sandbox image builds. * Strengthened build ID sanitization so unexpected input can’t affect generated Dockerfile instructions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Angel Mata <amata@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Angel Mata <amata@nvidia.com>
<!-- markdownlint-disable MD041 --> ## Summary Preserve Docker layer reuse for identical warm sandbox builds by leaving `NEMOCLAW_BUILD_ID` stable in stock OpenClaw and Hermes Dockerfiles. Custom `--from` Dockerfiles and managed agents that consume the compatibility argument retain the historical sanitized per-run rewrite. This is a signed, narrowed replacement for NVIDIA#6019. It intentionally drops that PR's late-`ENV` relocation because an empirical BuildKit control proved that changing any in-scope `ARG` still invalidates following `RUN` layers even when the instruction does not mention the argument. ## Related Issue Fixes NVIDIA#4682 ## Changes - Select build-ID policy from explicit provenance: preserve only the known-safe managed OpenClaw/Hermes Dockerfiles; custom `--from` and other managed agents retain unconditional rewriting. - Keep the stock Dockerfile's `ARG NEMOCLAW_BUILD_ID=default`, with an explicit comment that gateway tokens are generated at container startup and are not baked into image layers. - Add focused behavioral coverage for indirect custom consumers, newline sanitization, managed provenance selection, and OpenClaw/Hermes byte identity; move cache coverage out of the large shared patcher test. - Require patched stock Dockerfiles to remain byte-identical when only the per-run build ID changes. - Preserve the contributor’s cold/warm evidence: OpenClaw `20.9s` to `0.1s`; Hermes `21.5s` to `0.4s`, with real rebuilt-versus-`CACHED` BuildKit excerpts, the measurement boundary, and the ARG-scope caveat recorded in the test fixture. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — internal build-context/cache behavior; no user command, configuration, or support contract changes - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — the salvage preserves the existing ARG/ENV and runtime-token boundaries; custom values still pass through `sanitizeDockerArg`; no credential material is added to layers - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Git hooks passed during commit and push, or `npx prek run --from-ref main --to-ref HEAD` passes - [x] Targeted tests pass for changed behavior - [ ] Full `npm test` passes (broad runtime changes only) - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) Evidence: 37 focused patch/policy assertions; the normal hook passed 8,330 tests (8,299 passed, 31 skipped) plus source-shape, size, security, lint, DCO, and commitlint gates; CLI pre-push typecheck passed. Real BuildKit controls identified and then cached OpenClaw’s 3.7s plugin + 10.9s layout layers and Hermes’s 9.0s config + 4.8s layout layers. Parent timing record: NVIDIA#3776 (comment). Commits `22c39549bbb6d2aa1796647ecc26973293252545` and `c740d4cc3b63d541e7881e3d8206dc31d581501b` are GitHub Verified. --- Co-authored-by: Angel Mata <amata@nvidia.com> Signed-off-by: Angel Mata <amata@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved Docker build handling for onboarded environments, with smarter per-run build ID behavior for managed and custom Dockerfiles. * Added support for preserving stable build IDs in selected managed-agent flows to reduce unnecessary rebuilds. * **Bug Fixes** * Fixed cases where build ID changes could trigger avoidable cache misses during repeated sandbox image builds. * Strengthened build ID sanitization so unexpected input can’t affect generated Dockerfile instructions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Angel Mata <amata@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Angel Mata <amata@nvidia.com>
Summary
Move runtime defaults after build-time layers so identical sandbox rebuilds can reuse Docker cache. Keep stock build IDs stable unless custom Dockerfiles consume the build ID.
Related Issue
Fixes #4682
Changes
ENVdefaults after build-time config, messaging, plugin install, and permission layers.NEMOCLAW_BUILD_IDstable for stock Dockerfiles, while preserving cache-bust compatibility for custom Dockerfiles that consume it.20.9svs warm0.1s; Hermes cold21.5svs warm0.4s.Type of Change
Quality Gates
Verification
Verifiedin GitHubnpx prek run --from-ref main --to-ref HEADpassesnpm testpasses (broad runtime changes only)npm run docsbuilds without warnings (doc changes only)Signed-off-by: Angel Mata amata@nvidia.com
Summary by CodeRabbit