Skip to content

bazel/deps: Handle transitions in reachability aspect (re-land #5149) - #5152

Draft
phlax with Copilot wants to merge 2 commits into
mainfrom
copilot/reland-bazel-deps-matrix
Draft

bazel/deps: Handle transitions in reachability aspect (re-land #5149)#5152
phlax with Copilot wants to merge 2 commits into
mainfrom
copilot/reland-bazel-deps-matrix

Conversation

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Re-lands #5149 against current main, resolving conflicts with two features that landed in the interim: exec-cfg-safe exclusion settings and per-edge consumers[].attrs recording.

Conflict resolution

Exclusion settings (_excluded_edges/_excluded_patterns) are now carried through every branch of the split transition — the transition outputs include both the config-matrix flags and _EXCLUDED_EDGES_SETTING/_EXCLUDED_PATTERNS_SETTING. Only the flag settings appear in inputs (exclusions are written, never read from incoming settings). This preserves exec-configuration safety across all analyzed configs.

consumers[].attrs is accumulated in _record_edge as a dict and emitted as a sorted union — same semantics as roots. Correctly unioned across configs in the multiconfig case.

New capability (from #5149)

Split-transition multiconfig analysis with a fixed-at-construction-time flag set:

_envoy_dr = dependency_reachability_rule(
    flags = ["//bazel:wasm_runtime"],
    defines = True,
)
envoy_dependency_reachability = dependency_reachability_macro(_envoy_dr)

envoy_dependency_reachability(
    name = "dep-reachability",
    roots = ["//source/exe:envoy_main_common_with_core_extensions_lib"],
    configs = {
        "default":  {},
        "wasmtime": {"//bazel:wasm_runtime": "wasmtime"},
        "legacy":   {"wasm": "v8"},
    },
)

Output gains a per-repo configs list; all fields merge by union across configs (targets, configs, consumers[].roots, consumers[].attrs) with logical-OR for boolean fields (production, testonly).

The existing dependency_reachability is now dependency_reachability_macro(_dependency_reachability_rule()) — backward-compatible; excluded_edges/excluded_patterns/**kwargs pass through unchanged.

Exported helpers (for unit testing)

  • config_validation_error(configs, flags, defines) — validates config matrix against declared flags
  • merge_defines(existing, values) — merges --define assignments

New tests

  • reachability_config_validation_test.bzl / reachability_merge_defines_test.bzl — unit tests for the two exported helpers
  • reachability_test_rules.bzl — constructs a test rule varying //dependency/test:reachability_mode
  • reachability_test.sh — multiconfig assertions including consumers[].attrs union correctness

@netlify

netlify Bot commented Aug 24, 2026

Copy link
Copy Markdown

Deploy Preview for nifty-bassi-e26446 ready!

Name Link
🔨 Latest commit a3a630b
🔍 Latest deploy log https://app.netlify.com/projects/nifty-bassi-e26446/deploys/6a8c9d9bad020e00085361b7
😎 Deploy Preview https://deploy-preview-5152--nifty-bassi-e26446.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Supersedes #5149. Resolves conflicts by:
- Split transition carries both config-matrix flags and the two exclusion
  build settings (_excluded_edges, _excluded_patterns) so exec-cfg safety
  is preserved across all analyzed configurations.
- consumers[].attrs is accumulated and emitted as a sorted union across
  configs, consistent with roots union semantics.

New features (from #5149):
- dependency_reachability_rule(flags, defines) constructor for split transitions
- dependency_reachability_macro(impl) macro wrapper accepting configs dict
- Multi-config JSON output with per-repo configs list and union merge semantics
- _decode_configs, _encode_configs, config_validation_error, merge_defines helpers
  (config_validation_error and merge_defines exported for unit testing)

Kept from main:
- excluded_edges / excluded_patterns attrs on all rule forms
- _allowlist_function_transition
- consumers[].attrs in JSON output with union semantics across configs
- BuildSettingInfo transport for exec-cfg safe exclusions

Tests:
- reachability_test_rules.bzl: test rule constructed with reachability_mode flag
- reachability_config_validation_test.bzl: unit tests for config_validation_error
- reachability_merge_defines_test.bzl: unit tests for merge_defines
- reachability_test.sh: multi-config assertions including consumers[].attrs union
- BUILD: new string_flag, config_setting, variant filegroups, multiconfig target

Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot AI changed the title [WIP] Re-land change to handle transitions in reachability aspect bazel/deps: Handle transitions in reachability aspect (re-land #5149) Aug 24, 2026
Copilot AI requested a review from phlax August 24, 2026 19:38
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.

2 participants