Skip to content

agentHost: Share Dev Container CLI and server caches - #336914

Draft
Christof Marti (chrmarti) wants to merge 2 commits into
mainfrom
chrmarti/devcontainer-shared-server-cache
Draft

Christof Marti (chrmarti) wants to merge 2 commits into
mainfrom
chrmarti/devcontainer-shared-server-cache

Conversation

@chrmarti

@chrmarti Christof Marti (chrmarti) commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Avoid repeated CLI and VS Code Server downloads for fresh Dev Containers by sharing caches through the Docker vscode volume.

  • Add the volume mount for eligible image/Dockerfile configurations; respect configured mounts and leave Compose mounts configuration-owned.
  • Symlink only the container user's CLI servers directory to /vscode/<server-data-folder>/cli/servers/<linux|alpine>-<arch> before starting the CLI. Credentials, endpoint registration, logs, and other runtime state remain private to each container.
  • Cache commit-pinned bootstrap CLI downloads separately at /vscode/<server-data-folder>/cli/bin/<linux|alpine>-<arch>/<quality>-<commit>. The installer uses per-entry file locks and atomic publication, then installs an independent private copy. No pre-existing CLI is required to bootstrap the cache.
  • Keep five recent CLI entries per quality/platform, skipping locked entries. Private executables survive cache eviction and their self-updates cannot modify shared entries. Unpinned dev builds retain their existing private self-update flow.
  • Preserve existing private server-cache directories, differently targeted symlinks, and shared-cache ownership. Report cache setup failures and fall back to private storage/downloads; CLI caching also falls back when flock is unavailable.
  • Add helper, installer, and service tests, including real Linux shell tests, and document the storage contract.

Scope: Dev Containers only, whether launched locally or through SSH, Dev Tunnels, or WSL. Ordinary SSH and Dev Tunnel host CLI installations are unchanged.

Reviewer notes

No Rust CLI changes or migration of the Dev Containers extension's older server-cache layout. Server-cache locking, LRU, and eviction remain CLI-owned and unchanged; this does not introduce cross-container server in-use leases. The bootstrap CLI cache is separately installer-owned. Existing shared directories are not re-owned to force sharing across different UIDs.

Validation

  • Initial server-cache implementation: npm run compile-client passed, plus 60 focused service/cache/protocol/connector tests.
  • CLI-cache follow-up: npm run typecheck-client, fresh transpilation, scoped hygiene, and commit hooks passed; 125 focused cache/installer/Dev Container/SSH regression tests passed on macOS (Linux shell tests skipped there).
  • Final cache suites under Linux Docker as the non-root container user: 17 passing, covering concurrent cold installs, offline warm reuse, failed-download cleanup, stale staging recovery, independent copies, eviction, and locked-entry retention.
  • Real published CLI smoke: the first fresh container downloaded the pinned executable; a second fresh container reused it with networking disabled, and its private copy still ran after shared-cache eviction.
  • During server-cache implementation, connected real Agent Hosts in two fresh containers and verified reuse of the same extracted server Node inode.

UI smoke validation remains blocked: the earlier local/SSH smoke run failed in setup before workbench startup, without reaching cache or container behavior. It is not counted as passing.

Link only the CLI servers directory to a platform-partitioned cache in the vscode volume. Keep credentials and runtime state private, preserve existing caches and mount configuration, and report optional-cache fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 20, 2026 12:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

An unwritable existing shared-cache symlink prevents the promised private-cache fallback, and creation behavior lacks direct shell coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds shared VS Code Server caching for Dev Containers through the vscode Docker volume.

Changes:

  • Adds cache mount detection, creation, partitioning, and symlink setup.
  • Integrates graceful fallback into Dev Container startup.
  • Adds tests and documents the storage contract.
File Description
REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md Documents shared-cache behavior.
devContainerServerCache.test.ts Tests cache paths, mounts, and symlinks.
devContainerAgentHostService.test.ts Tests service integration and fallback.
devContainerServerCache.ts Implements cache helpers and shell commands.
devContainerAgentHostService.ts Integrates cache setup into container startup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +82 to +84
'test -d "$cache_dir" && test -w "$cache_dir" || { echo "Shared server cache is not writable" >&2; exit 1; }',
'for entry in "$cache_dir/lru.json" "$cache_dir/.locks"; do',
' if [ -L "$entry" ] || { [ -e "$entry" ] && [ ! -w "$entry" ]; }; then echo "Shared server cache metadata is not writable" >&2; exit 1; fi',
}

/** Creates only missing cache directories, without changing ownership of an existing shared cache. */
export function buildCreateDevContainerServerCacheCommand(cachePath: string, uid: string, gid: string): string {
Cache commit-pinned CLI executables in the shared vscode volume with per-entry file locks and atomic publication. Install private copies so self-update and cache eviction cannot affect other containers. Keep ordinary SSH and Dev Tunnel host installation unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chrmarti Christof Marti (chrmarti) changed the title agentHost: Share Dev Container server caches through the vscode volume agentHost: Share Dev Container CLI and server caches Sep 20, 2026
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.

2 participants