Skip to content

fix(devcontainer): stop VS Code from watching agent worktrees and clones #6453

Closed

Description

@dan-petty

Problem

In the devcontainer, one VS Code server process holds 524137 of the 524288 inotify watches of the host user (/proc/sys/fs/inotify/max_user_watches; counted from /proc/<pid>/fdinfo on 2026-11-19). Other programs then cannot add a watch. Found while testing the podman-in-podman Feature: aardvark-dns 1.17 on debian:sid panics when it cannot watch /etc/resolv.conf, so container name resolution fails ("ping: bad address"), and rootful network removal fails sometimes ("aardvark-dns failed to start"). File watchers of tests and tools can fail in the same way.

The workspace holds about 21 GB of agent worktrees under .data/agent/worktrees/ and about 31 GB of repository clones under repos/ (repos.base_dir), each with its own .venv, caches and build output. .vscode/settings.json and .devcontainer/devcontainer.json set no files.watcherExclude, so VS Code watches all of them. VS Code's default exclude list covers only .git/objects, .git/subtree-cache, node_modules/*/** and .hg/store.

Expected

  • files.watcherExclude in .vscode/settings.json (or the VS Code customizations of .devcontainer/devcontainer.json, one place only) excludes .data/**, repos/**, **/.venv/** and the tool caches (.mypy_cache, .ruff_cache, .pytest_cache, mutants).
  • After a window reload, the VS Code server holds a small share of the watches (measure it again from /proc/<pid>/fdinfo), and docker compose exec b ping -c1 a works in a rootless podman-in-podman container on debian:sid.
  • No test of a config value (owner rule); the proof is the measurement in the PR.

Proposed design

Problem statement

One VS Code server process holds 524137 of the 524288 inotify watches of the host user. The workspace holds about 21 GB of agent worktrees under .data/agent/worktrees/ and about 31 GB of clones under repos/, each with its own virtual environment and caches, and VS Code watches them all. Other programs cannot add a watch, so aardvark-dns panics on /etc/resolv.conf and container name resolution fails. The change excludes these folders from the VS Code file watcher.

Acceptance criteria

Requirement: The workspace excludes the agent folders

The VS Code workspace settings SHALL set files.watcherExclude for the agent worktrees, the repository clones, the virtual environments and the tool caches.

Scenario: The key is in one settings file

  • WHEN the developer runs grep -rn 'files.watcherExclude' .vscode .devcontainer at the workspace root
  • THEN the command prints one line, and the pull request records that line

Requirement: The settings file stays valid JSON

The change SHALL keep .vscode/settings.json valid JSON.

Scenario: The JSON parser reads the file

  • WHEN the developer runs python -m json.tool .vscode/settings.json
  • THEN the command prints the parsed content and exits 0

Requirement: The VS Code server holds few watches

The VS Code server in the devcontainer SHALL hold less than 10% of max_user_watches after the change.

Scenario: The watch count after a window reload

  • WHEN the developer counts the inotify lines of /proc/<pid>/fdinfo for the VS Code server process after a window reload
  • THEN the count is less than 10% of the value of /proc/sys/fs/inotify/max_user_watches, and the pull request shows the count before and after the change

Requirement: A container resolves the name of its peer

The devcontainer SHALL let a rootless podman-in-podman container resolve the name of a peer container after the window reload.

Scenario: Ping the peer container

  • WHEN the developer runs docker compose exec b ping -c1 a in the rootless podman-in-podman environment on debian:sid
  • THEN the command prints one reply and exits 0

Existing Tool Considered

No alternatives check has run. The need is the built-in VS Code setting files.watcherExclude, and no separate open tool or library covers it. The change builds no code: it adds one key to .vscode/settings.json, and the devcontainer image does not change.

Key questions

  • Which file holds files.watcherExclude?: Put the key in .vscode/settings.json. That file holds one key in one place and applies to the workspace in the devcontainer. The devcontainer customizations hold each setting twice, under vscode and under antigravity, so the key would go in two blocks. (best practice) [sources: .vscode/settings.json, .devcontainer/devcontainer.json]
    • Chosen: Workspace file .vscode/settings.json. One place, one key, and VS Code reads it in the devcontainer.
    • Rejected: Devcontainer customizations .devcontainer/devcontainer.json. The file repeats each setting under vscode and antigravity, so the key would sit in two blocks.
  • Which glob patterns exclude the worktrees, the clones and the caches?: Use **/.data/**, **/repos/**, **/.venv/**, **/.mypy_cache/**, **/.ruff_cache/**, **/.pytest_cache/** and **/mutants/**. Add the four default keys of VS Code too, so the block keeps them. (best practice) [sources: .vscode/settings.json]
    • Rejected: Root-anchored patterns such as .data/**. They match only at the workspace root, and a clone can hold a nested .data folder.
    • Chosen: **/-prefixed patterns. They match at any depth, and VS Code matches them against the absolute path.
    • Rejected: Project patterns only, with no default keys. A block that replaces the defaults would watch the .git/objects of the workspace again.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    status/new
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. The watcher exhaustion causes DNS failures, test failures, and tool failures in the devcontainer, degrading the development workflow.
    • Related: fix(devcontainer): raise the process limit of the container #3722, which asks for a different change. Both fix devcontainer resource exhaustion, but 3722 raises the process limit while this candidate excludes file paths from VS Code's inotify watcher.
  3. added
    effort/low
    value/high
    scope/devcontainer
    priority/p1-high
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    status/in-review
    and removed
    status/in-progress
    on Nov 19, 2026
  6. removed
    status/in-review
    owner/agent
    on Nov 19, 2026
  7. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-19 21:54 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p1-highscope/devcontainersource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions