From aa386137da2733148829ad89f461b5b4ac07acf9 Mon Sep 17 00:00:00 2001 From: Jochen Hoenle Date: Mon, 3 Aug 2026 15:25:32 +0200 Subject: [PATCH] [rules score] wire unit validation into dependable element --- .../private/dependable_element.bzl | 20 +++++++++++++++++-- bazel/rules/rules_score/private/unit.bzl | 1 + bazel/rules/rules_score/providers.bzl | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bazel/rules/rules_score/private/dependable_element.bzl b/bazel/rules/rules_score/private/dependable_element.bzl index d806153d..2bbdfa92 100644 --- a/bazel/rules/rules_score/private/dependable_element.bzl +++ b/bazel/rules/rules_score/private/dependable_element.bzl @@ -914,6 +914,12 @@ def _dependable_element_index_impl(ctx): output_files.append(arch_json) output_files.extend(validation_output_files) + unit_validation_output_files = [] + for unit_target in all_units.values(): + unit_validation_output_files.append( + _symlink_validation_log(ctx, unit_target[UnitInfo].validation_log), + ) + # ========================================================================= # Safety Certification Validation: certified scope and integrity level checks # ========================================================================= @@ -1396,7 +1402,7 @@ def _dependable_element_index_impl(ctx): chain_forwarded_lobster = chain_forwarded_lobster_depset, ), own_assumptions_of_use_info, - OutputGroupInfo(debug = depset(validation_output_files)), + OutputGroupInfo(debug = depset(validation_output_files + unit_validation_output_files)), ] def _dependable_element_index_attrs(): @@ -1569,12 +1575,22 @@ def _dependable_element_impl(ctx): if lobster_info.lobster_html_report: lobster_default_files.append(lobster_info.lobster_html_report) + # Force this element's own units' design-vs-implementation validation to + # run whenever "" itself is built/tested — kept out of the index's + # sphinx_module srcs (see _dependable_element_index_impl) so that + # downstream modules merely consuming "_doc" via `deps` for HTML + # merging don't also re-trigger it under their own build configuration. + unit_validation_files = index_dep[OutputGroupInfo].debug.to_list() + return [ # DefaultInfo: lobster report file(s) + Sphinx HTML docs so that # ``bazel build `` produces exactly the final user-facing outputs. DefaultInfo( executable = test_executable, - files = depset(lobster_default_files, transitive = [sphinx_dep[DefaultInfo].files]), + files = depset( + lobster_default_files + unit_validation_files, + transitive = [sphinx_dep[DefaultInfo].files], + ), runfiles = runfiles, ), # Sphinx docs providers: forwarded from sphinx_module so callers can use diff --git a/bazel/rules/rules_score/private/unit.bzl b/bazel/rules/rules_score/private/unit.bzl index 4cc1f7fb..657c1a14 100644 --- a/bazel/rules/rules_score/private/unit.bzl +++ b/bazel/rules/rules_score/private/unit.bzl @@ -147,6 +147,7 @@ def _unit_impl(ctx): implementation = depset(ctx.attr.implementation), tests = tests_depset, dependent_labels = depset(transitive = collected_dependent_labels), + validation_log = validation_log, ), SphinxSourcesInfo( srcs = all_files, diff --git a/bazel/rules/rules_score/providers.bzl b/bazel/rules/rules_score/providers.bzl index d9d4554b..af400be4 100644 --- a/bazel/rules/rules_score/providers.bzl +++ b/bazel/rules/rules_score/providers.bzl @@ -84,6 +84,7 @@ UnitInfo = provider( "implementation": "Depset of implementation targets (cc_library, rust_library, etc.).", "tests": "Depset of test targets (cc_test, rust_test, etc.).", "dependent_labels": "Depset of Labels that this unit's implementation depends on transitively (used for certification scope validation).", + "validation_log": "Struct with file and name fields describing the UnitValidate (design-vs-implementation) log entry produced by this unit target.", }, )