← Back to Pull requests

Watch Xcode version metadata to invalidate repository config #655

Merged
ssarad merged 2 files (42 lines) on Oct 06, 2026 18:17 UTC
View on GitHub
ssarad ssarad commented on Sep 30, 2026 02:13 UTC
Author

Watch Contents/Info.plist and Contents/version.plist so upgrading Xcode at the same path invalidates the repository and reruns discovery.

Diff: 42 lines (+41 / -1) across 2 files Reviewer: keith Review duration: 9603m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.50) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 42 lines diff across 2 files
0.50
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.87 · 5 substantive comment(s)
0.87
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.225
Sensitive Paths sensitive_paths
0.050
Real PR Conversation Timeline
19 items
keith keith commented on Sep 30, 2026 18:28 UTC
Contributor

what if we just always watched /var/db/xcode_select_link/../version.plist if it existed (i imagine in the CLT case it would not?) that way we could avoid the xcode-select call. might also have to consider /var/db/xcode_select_link/Contents/version.plist, i'd have to check if it normalizes that symlink to Contents/Developer or not

ssarad ssarad commented on Oct 01, 2026 01:28 UTC
Author

@keith hrm. That could avoid the subprocess when DEVELOPER_DIR is unset. Do you think we still need to handle the override? On my machine /var/db/xcode_select_link points to CLT, but builds select Xcode through --repo_env=DEVELOPER_DIR. I’ll check the symlink layout and whether we can derive the plist paths directly for both cases. I’d keep watching Info.plist alongside version.plist, since the locator reads the release version from one and the build number from the other.

ssarad ssarad commented on Oct 01, 2026 01:47 UTC
Author

Did a bit of cleanup, lmk 🙏

keith keith commented on code on Oct 01, 2026 23:58 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:

what do we get from watching both?

keith keith commented on code on Oct 01, 2026 23:58 UTC
Code Review
crosstool/osx_cc_configure.bzl:1
@@ -172,6 +172,8 @@ def configure_osx_toolchain(repository_ctx):
         (xcode_toolchains, xcodeloc_err) = run_xcode_locator(repository_ctx, xcode_locator)
         if not xcode_toolchains:
             return False, xcodeloc_err
+    else:
+        watch_selected_xcode(repository_ctx)

if we run run_xcode_locator we might as well watch every xcode in the result, if we can easily get those from the existing call

keith keith commented on code on Oct 02, 2026 00:00 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:
+        repository_ctx.watch(developer_path.dirname.get_child(filename))
+
+def watch_selected_xcode(repository_ctx):
+    """Watches the selected Xcode's version files.
+
+    Args:
+      repository_ctx: The repository context.
+    """
+    if not repository_ctx.os.name.startswith("mac os"):
+        return
+
+    developer_dir = repository_ctx.getenv("DEVELOPER_DIR", "")
+    selected_path = repository_ctx.path(developer_dir or "/var/db/xcode_select_link")
+
+    repository_ctx.watch(selected_path)

what does this watch do? either way we probably want it after the .exists call?

keith keith commented on code on Oct 02, 2026 00:02 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:
+        repository_ctx.watch(developer_path.dirname.get_child(filename))
+
+def watch_selected_xcode(repository_ctx):
+    """Watches the selected Xcode's version files.
+
+    Args:
+      repository_ctx: The repository context.
+    """
+    if not repository_ctx.os.name.startswith("mac os"):
+        return
+
+    developer_dir = repository_ctx.getenv("DEVELOPER_DIR", "")
+    selected_path = repository_ctx.path(developer_dir or "/var/db/xcode_select_link")
+
+    repository_ctx.watch(selected_path)
+    if not selected_path.exists:
+        return
+
+    # Resolve first; ".." would be normalized before following the symlink.
+    resolved_path = selected_path.realpath
+    if resolved_path.basename.endswith(".app"):
+        developer_path = selected_path.get_child("Contents", "Developer")
+    elif developer_dir:
+        developer_path = selected_path
+    else:
+        developer_path = resolved_path

can you simplify this to only have selected_path?

keith keith commented on code on Oct 02, 2026 00:02 UTC
Code Review
crosstool/osx_cc_configure.bzl:1
@@ -172,6 +172,8 @@ def configure_osx_toolchain(repository_ctx):
         (xcode_toolchains, xcodeloc_err) = run_xcode_locator(repository_ctx, xcode_locator)
         if not xcode_toolchains:
             return False, xcodeloc_err
+    else:
+        watch_selected_xcode(repository_ctx)

ah i see now we are doing that, i'd throw in a comment about how that is elsewhere

keith keith commented on Oct 02, 2026 00:02 UTC
Reviewer

looking viable to me!

ssarad ssarad commented on code on Oct 02, 2026 03:01 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:

The locator reads CFBundleShortVersionString from Info.plist and ProductBuildVersion from Version.plist, so this catches build-only updates even when the release version stays the same.

ssarad ssarad commented on code on Oct 02, 2026 03:04 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:
+        repository_ctx.watch(developer_path.dirname.get_child(filename))
+
+def watch_selected_xcode(repository_ctx):
+    """Watches the selected Xcode's version files.
+
+    Args:
+      repository_ctx: The repository context.
+    """
+    if not repository_ctx.os.name.startswith("mac os"):
+        return
+
+    developer_dir = repository_ctx.getenv("DEVELOPER_DIR", "")
+    selected_path = repository_ctx.path(developer_dir or "/var/db/xcode_select_link")
+
+    repository_ctx.watch(selected_path)

This watches the selected path appearing or disappearing. It needs to precede the .exists check so we also track a currently missing selection becoming available. Atleast that was my thought process but do you think this is still viable after exists?

ssarad ssarad commented on code on Oct 02, 2026 03:05 UTC
Code Review
crosstool/osx_cc_configure.bzl:1
@@ -172,6 +172,8 @@ def configure_osx_toolchain(repository_ctx):
         (xcode_toolchains, xcodeloc_err) = run_xcode_locator(repository_ctx, xcode_locator)
         if not xcode_toolchains:
             return False, xcodeloc_err
+    else:
+        watch_selected_xcode(repository_ctx)

Yep, run_xcode_locator already watches the version metadata for every Xcode it discovers. I'll add a comment at this call site to make that clear

ssarad ssarad commented on code on Oct 02, 2026 03:06 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:
+        repository_ctx.watch(developer_path.dirname.get_child(filename))
+
+def watch_selected_xcode(repository_ctx):
+    """Watches the selected Xcode's version files.
+
+    Args:
+      repository_ctx: The repository context.
+    """
+    if not repository_ctx.os.name.startswith("mac os"):
+        return
+
+    developer_dir = repository_ctx.getenv("DEVELOPER_DIR", "")
+    selected_path = repository_ctx.path(developer_dir or "/var/db/xcode_select_link")
+
+    repository_ctx.watch(selected_path)
+    if not selected_path.exists:
+        return
+
+    # Resolve first; ".." would be normalized before following the symlink.
+    resolved_path = selected_path.realpath
+    if resolved_path.basename.endswith(".app"):
+        developer_path = selected_path.get_child("Contents", "Developer")
+    elif developer_dir:
+        developer_path = selected_path
+    else:
+        developer_path = resolved_path

Done!

ssarad ssarad commented on Oct 05, 2026 03:04 UTC
Author

@keith Added some more cleanup if you can review when you get a chance, thank you!

keith keith commented on code on Oct 05, 2026 17:55 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:

isn't version.plist enough?

% plutil -p version.plist
{
  "BuildVersion" => "2"
  "CFBundleShortVersionString" => "26.5"
  "CFBundleVersion" => "24943"
  "ProductBuildVersion" => "17F42"
  "ProjectName" => "IDEApplication"
  "SourceVersion" => "24943000000000000"
}

seems like this has all the version components but realistically just the ProductBuildVersion here is probably enough?

ssarad ssarad commented on code on Oct 06, 2026 02:21 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:

Hmmm, yeah I think that is likely fine then, pushed it

ssarad ssarad commented on code on Oct 06, 2026 02:23 UTC
Code Review
xcode/xcode_configure.bzl:1
@@ -19,6 +19,40 @@
 
 OSX_EXECUTE_TIMEOUT = 600
 
+def _watch_xcode_version_files(repository_ctx, developer_dir):
+    developer_path = repository_ctx.path(developer_dir)
+    if developer_path.basename != "Developer" or developer_path.dirname.basename != "Contents":
+        return
+
+    for filename in ["Info.plist", "version.plist"]:

Should be good now, thanks! @keith

keith keith approved these changes on Oct 06, 2026 18:15 UTC
Approved Reviewer

Approved these changes.

Reviewers
Assignees
ssarad ssarad
Labels
risk: low confidence: 89% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 50.1% (MEDIUM) · Higher = larger blast radius
50.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 89% · Lower = rushed or shallow review
89%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 5.5% · Safe to merge
5.5%