← Back to Pull requests

Validate extra link-time callbacks with Starlark Args #827

Closed
dzbarsky closed this pull request without merging on Nov 01, 2026 05:01 UTC
View on GitHub
dzbarsky dzbarsky commented on Aug 02, 2026 21:29 UTC
Author

Validate extra link-time library callbacks with ctx.actions.args().add_all([], map_each = callback) immediately before invocation. Args.add_all performs the same top-level-function check as _cc_internal.check_toplevel, so the C++ Java helper is no longer needed.

Validation: 88 C++ common and binary analysis tests passed, including new tests for top-level and nested callbacks.

Diff: 149 lines (+145 / -4) across 2 files Reviewer: lilygorsheneva Review duration: 130052m
All Vouch review confidence checks passed
Residual risk 0.06 = Change Risk (0.34) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.34 · 149 lines diff across 2 files
0.34
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.73 · 5 substantive comment(s)
0.73
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
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.300
Real PR Conversation Timeline
9 items
lilygorsheneva lilygorsheneva commented on code on Aug 14, 2026 22:17 UTC
Code Review
tests/cc/common/cc_common_test.bzl:1

Do you know if this function was previously under-tested or if there's a set of tests in bazelbuild/bazel that should be migrated over into rules_cc?

lilygorsheneva lilygorsheneva commented on code on Aug 14, 2026 22:22 UTC
Code Review
cc/private/link/create_extra_link_time_library.bzl:1
@@ -170,6 +169,7 @@ def build_libraries(extra_libraries, ctx, static_mode, for_dynamic_library):
     transitive_runtime_libraries = []
     additional_stamp_infos = []
     for library in extra_libraries:
+        ctx.actions.args().add_all([], map_each = library.build_library_func)

This needs a comment describing what it does; I acknowledge its benefit but it's hacky.

lilygorsheneva lilygorsheneva commented on code on Aug 14, 2026 22:27 UTC
Code Review
cc/private/link/create_extra_link_time_library.bzl:1

The args.add_all documentation says map_each must be a top-level def "To avoid unintended retention of large analysis-phase data structures into the execution phase".

If we choose to abuse args.add_all to type check, I feel like we should document that we have a different intent (though we also want to save memory of course).

lilygorsheneva lilygorsheneva requested changes on Sep 11, 2026 22:00 UTC
Changes Requested Reviewer

Requested changes.

dzbarsky dzbarsky commented on code on Sep 13, 2026 16:06 UTC
Code Review
tests/cc/common/cc_common_test.bzl:1

Bazel's public C++ test only checked private API access; I couldn’t find callback tests to migrate. Bazel does have a generic Args test for nested functions and lambdas. This PR now tests nested callback rejection, rejection of built-ins and None, and that a shared top-level callback receives the merged inputs.

dzbarsky dzbarsky commented on Sep 13, 2026 16:08 UTC
Reviewer

OK, addressed review feedback. I still think (as I'm sure you do) that this is kinda hacky, up to yall if you think its worth the benefit of removing these Java APIs

lilygorsheneva lilygorsheneva approved these changes on Sep 14, 2026 20:47 UTC
Approved Reviewer

Approved these changes.

lilygorsheneva lilygorsheneva commented on Sep 14, 2026 20:48 UTC
Contributor

I favor getting c-specific things out of bazel; if the second reviewer thinks it's too hacky I'll push for making this a non-c bazel builtin

Assignees
dzbarsky dzbarsky
Labels
risk: low confidence: 83.2% reviewed
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: 34.4% (LOW) · Higher = larger blast radius
34.4%
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: 83.2% · Lower = rushed or shallow review
83.2%
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.8% · Safe to merge
5.8%