Skip to content

Watch host_key.py so a module upgrade reaches existing output bases - #6

Merged
jeffwall-curlewlabs merged 2 commits into
mainfrom
watch-host-key
Oct 13, 2026
Merged

jeffwall-curlewlabs merged 2 commits into
mainfrom
watch-host-key

Conversation

@jeffwall-curlewlabs

Copy link
Copy Markdown
Contributor

The rule runs host_key.py through rctx.path(Label("//:host_key.py")), and
Bazel 9.2.0 records nothing for a file reached that way. So an upgrade that
changes only the script, with defs.bzl and the rule's attributes unchanged,
leaves the rule key and every recorded input equal: an existing output base
keeps the old script's key and watches until some other watched path changes.

0.0.3 was such an upgrade. In a consumer's output base that had run 0.0.2 (with
the #2 and #3 changes applied as patches), fetching 0.0.3 left the repository's
marker as 0.0.2 wrote it, without #4's
/var/db/xcode_select_link/usr/bin/xcodebuild watch. A fresh output base
recorded that watch. Both computed the same key, d2cf2921....

Change

  • defs.bzl watches //:host_key.py before running it.
  • tests/check_platform.py runs a scratch copy of the module, so a new last
    step can replace the copy's host_key.py in a running server with one that
    reports another key, and expect the action to run again.
  • README: the rule watches its own script, so an upgrade reaches an existing
    output base.
  • Release 0.0.4: MODULE.bazel and the README snippet.

The key's digest input is unchanged. Because defs.bzl changes, upgrading to
0.0.4 re-runs the rule once in every output base, which computes the same key.

Verification

  • tests/check_platform.py passes on macOS 26.7 with Bazel 9.2.0; the host key
    stays d2cf2921.... Run against a copy of the module without the watch, it
    fails at the new step: host_key.py upgraded, running server: expected executed, got reused.
  • buildifier 8.5.1, Ruff 0.16.7 and mypy 2.3.1 pass through pre-commit.

The rule runs host_key.py through rctx.path, which Bazel does not
record. An upgrade that changed only the script, with defs.bzl and the
rule's attributes unchanged, left an existing output base on the old
script's key and watches until some other watched path changed. 0.0.3
was such an upgrade: its watches through links reached a fresh output
base but not one that had run 0.0.2.

The real-Bazel check now runs a scratch copy of the module, replaces
its host_key.py in a running server, and expects the action to run
again; without the watch that step reuses the old result.
Carries the rule's watch on its own host_key.py, so upgrading to this
release re-runs the rule in every output base, and a later upgrade that
changes only the script reaches existing output bases too.
@jeffwall-curlewlabs
jeffwall-curlewlabs merged commit 19a2860 into main Oct 13, 2026
9 checks passed
@jeffwall-curlewlabs
jeffwall-curlewlabs deleted the watch-host-key branch October 13, 2026 02:32
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