Skip to content

Watch linked directories through their links - #4

Merged
jeffwall-curlewlabs merged 1 commit into
mainfrom
watch-through-links
Oct 13, 2026
Merged

jeffwall-curlewlabs merged 1 commit into
mainfrom
watch-through-links

Conversation

@jeffwall-curlewlabs

Copy link
Copy Markdown
Contributor

Bazel 9.2.0 records a watched FILE input that resolves to a directory as the
literal DIR (RepoRecordedInput.File.fileValueToMarkerValue). It records no
target, so a link moved to another directory looks unchanged and the key goes
stale.

Reproduced with 0.0.2. A search path of ["<scratch>/tools"] with
tools -> a, where a/t holds one, gave key 1be3bef7de01. Running
ln -sfn b tools, where b/t holds two, left the key unchanged in the
running server and after a restart. Changing the bytes of a/t did re-key.

Change

  • search_path_identity watches listings and entries through the directory as
    named, not its resolved path, so the watches follow a linked directory.
  • macos_fields also watches /var/db/xcode_select_link/usr/bin/xcodebuild.
    The selection link itself only ever records DIR, and the version.plist
    watch is the old selection's. xcodebuild reached through the link differs
    between Xcode builds: 17F113 and 27A266a on one Mac. The Command Line Tools
    have no xcodebuild, so moving between them and Xcode flips the watch to or
    from absent.
  • README: what is watched through links, and the one case still unseen. A link
    moved to a copy with the same names and bytes leaves the key naming the old
    path until something else recomputes it; the tools that run are the same.

The key's digest input is unchanged, so no host gets a new key. On a Linux CI
host the key stays 76a1aef1... with the same 1,305 watched files, which are now
watched through /bin, a link to usr/bin. On macOS 26.7 the key stays
d2cf2921..., with one more watched file.

Verification

  • tests/check_platform.py names its scratch tools through a link to their
    directory, and moves the link in a running server as a new last step. It
    passes. With main's host_key.py it fails at that step: expected executed, got reused.
  • New unit tests: a linked search path directory is watched through the link,
    and on macOS the selection is watched through its xcodebuild. Removing
    either watch fails its test. Python 3.14 and Xcode's 3.9.6.
  • Ruff 0.16.7 and mypy 2.3.1 --strict pass.

Bazel records a watched path that resolves to a directory as only that: a
directory. A link moved from one directory to another therefore looks
unchanged, and the key went stale in two places:

- A search path directory named by a link was listed, and its entries were
  watched, under the resolved path. Pointing the link at other tools changed
  nothing Bazel watched, so the key kept the old tools, in a running server
  and in a new one.
- The xcode-select selection is a link to the developer directory. Its watch
  recorded only "directory", and the version file watched was the old
  selection's, so selecting another Xcode left the key on the old one.

Search path listings and entries are now watched through the directory as
named, so they follow the link. The selection is watched through
usr/bin/xcodebuild under it, whose bytes differ between Xcode builds and which
the Command Line Tools lack. Bazel still cannot see a link moved to a copy
with the same names and bytes; the README says so.

What the key digests is unchanged, so every host keeps its key. Only watch
paths move: on a Linux host where /bin links to usr/bin, the same files are now
watched through /bin.

tests/check_platform.py now names its scratch tools through a link and moves
the link in a running server; the previous host_key.py reuses the old result
at that step, and this one executes.
@jeffwall-curlewlabs jeffwall-curlewlabs mentioned this pull request Oct 13, 2026
@jeffwall-curlewlabs
jeffwall-curlewlabs merged commit 36f614b into main Oct 13, 2026
9 checks passed
@jeffwall-curlewlabs
jeffwall-curlewlabs deleted the watch-through-links branch October 13, 2026 01:57
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.

1 participant