Skip to content

repro: referencing Communication's mw_com_rst breaks //:docs (demo, do not merge) - #379

Draft
antonkri wants to merge 1 commit into
mainfrom
repro/dependable-element-testonly
Draft

antonkri wants to merge 1 commit into
mainfrom
repro/dependable-element-testonly

Conversation

@antonkri

@antonkri antonkri commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Draft / demonstration only — not for merge. //:docs is deliberately broken.

Problem

Communication generates verification reports for its dependable elements
(mw_com, message_passing) via the dependable_element rule from
eclipse-score/tooling. We would like to
mount those pages into the reference integration documentation instead of only
linking them (#378). This PR shows why that does not work today.

The change

One line in the root BUILD:

docs(
    bundles = DOCS_BUNDLES,
    data = ["@score_communication//score/mw/com/dependability:mw_com_rst"],
    known_good = "known_good.json",
    source_dir = "docs",
)

<name>_rst is the sphinx_docs_library that dependable_element generates in
"Step 4" precisely so that an external Sphinx build can include the element's pages.
docs(data = ...) is the documented way to add files to this project's root bundle, so
this is the natural attempt.

Result

bazel build --nobuild \
  --extra_toolchains=//bazel/toolchains:score_ref_int_libclang_toolchain \
  //:docs
ERROR: BUILD:35:5: in _docs_bundle rule //:docs_bundle: non-test target
'//:docs_bundle' depends on testonly target
'@@score_communication+//score/mw/com/dependability:mw_com_rst'
and doesn't have testonly attribute set
ERROR: Analysis of target '//:docs' failed; build aborted: Analysis failed

CI hits the same error through //:docs_shim. Communication is pinned at 313f1178
per known_good.json. The --extra_toolchains flag is unrelated — without it analysis
stops earlier on a missing libclang toolchain.
dependable_element_message_passing_rst behaves identically.

Why testonly = False is not the answer

dependable_element has a testonly parameter that only defaults to True, so the
obvious idea is to flip it. It does not help: the graph underneath <name>_rst is built
out of Bazel test rules, which are unconditionally testonly.

<name>_rst has srcs = [":<name>_index"], and <name>_index reaches test rules
through three independent attributes:

$ bazel query 'kind(".*_test rule", deps(@score_communication//score/mw/com/dependability:mw_com_rst))'
@score_communication//score/mw/com/impl:frontend_component
@score_communication//score/mw/com/impl/bindings:bindings
@score_communication//score/mw/com/impl/bindings/lola:lola_component
@score_communication//score/mw/com/impl/bindings/mock_binding:mock_component
@score_communication//third_party/score_baselibs:bitmanipulation
@score_communication//third_party/score_baselibs:bitmanipulation_component
@score_communication//third_party/score_baselibs:containers
@score_communication//third_party/score_baselibs:containers_component
@score_communication//third_party/score_baselibs:futurecpp
@score_communication//third_party/score_baselibs:futurecpp_component
@score_communication//third_party/score_baselibs:os
@score_communication//third_party/score_baselibs:os_component
Attribute of _dependable_element_index Points at Rule class Read in the rule impl?
components (mandatory) <x>_component / <x> from component() _component_test (component.bzl:359) yes, via aspect
deps <dep> of other dependable elements _dependable_element_test (dependable_element.bzl:2036, test = True) only dep.label.name (line 693)
tests real test targets cc_test etc. never — no ctx.attr.tests anywhere

The components row is the important one: component() creates its main target as a
test rule, and components is a mandatory attribute of dependable_element. The
contamination is therefore structural, not an artifact of the two optional attributes.

Possible directions (for discussion)

  1. deps and tests are cheap wins. ctx.attr.tests is never read, and
    ctx.attr.deps is only used for dep.label.name — no providers, no files (the real
    provider edge is processed_deps → <dep>_index). Making deps a string_list and
    dropping tests removes two of three paths with no loss of functionality.
  2. components needs a split into a docs-producing target and a traceability test
    target — the same split that already exists for <name> vs <name>_doc.
  3. Or keep linking instead of mounting, as done in docs: link Communication's dependable_element verification reports #378.

Any fix belongs in eclipse-score/tooling, not here. This PR only makes the current
state reproducible.

Contents

  • BUILD — the one data = [...] line that breaks //:docs
  • repro/dependable_element_testonly/README.md — full analysis, commands, expected output

Reference mw_com_rst - the sphinx_docs_library that dependable_element
generates so external Sphinx builds can include a dependable element's
pages - from docs(data = ...) in the root BUILD.

//:docs then fails analysis:

  non-test target '//:docs_bundle' depends on testonly target
  '@@score_communication+//score/mw/com/dependability:mw_com_rst'
  and doesn't have testonly attribute set

testonly = False on dependable_element does not help: <name>_index reaches
Bazel test rules through components (mandatory, component() creates a test
rule), deps (other elements' _dependable_element_test) and tests. Test
rules are unconditionally testonly.

Not for merge - demonstration only.
@antonkri
antonkri force-pushed the repro/dependable-element-testonly branch from cf70fa5 to d483cc8 Compare September 29, 2026 14:23
@antonkri antonkri changed the title repro: dependable_element docs are unavoidably testonly (demo, do not merge) repro: referencing Communication's mw_com_rst breaks //:docs (demo, do not merge) Sep 29, 2026
@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

This branch has not been deployed

No deployments
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