Skip to content

test: observational baseline for the wrapped-closure precision gap (#4572)#14365

Merged
Alizter merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-test-wrapped-closure-precision
Apr 29, 2026
Merged

test: observational baseline for the wrapped-closure precision gap (#4572)#14365
Alizter merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-test-wrapped-closure-precision

Conversation

@robinbb
Copy link
Copy Markdown
Collaborator

@robinbb robinbb commented Apr 28, 2026

Summary

Adds a cram test recording which compile-rule target_files
rebuild when a consumer references a wrapped sibling library
whose Lib.closure includes a transitively-reached unwrapped
library, and an unread module of that transitive library is
edited.

Setup

  • dep_lib is unwrapped with two entry modules: reached_module
    (transitively reached via an alias chain) and unreached_module
    (which no source in the test reaches).
  • lib_re_export is wrapped (dune auto-generates the wrapper) with
    a single child pprint that aliases only reached_module of
    dep_lib.
  • consumer_lib writes Lib_re_export.Pprint.Re.x, naming
    Lib_re_export in source.

What the test records

Editing unreached_module.mli rebuilds the consumer on trunk
today: the cctx-wide -I/-H glob covers dep_lib's objdir,
so any .cmi content change in dep_lib invalidates the
consumer regardless of whether the change is to a module the
consumer's alias chain actually reaches.

A precision-perfect filter could observe that pprint's ocamldep
output names only reached_module and emit a per-module dep on
reached_module.cmi alone — leaving the consumer untouched on
unreached_module.mli changes.

The test asserts the current rebuild list (the consumer's
.cmi/.cmti rule re-runs) so a future filter improvement that
closes the precision gap will flip the array to [].

Relationship to #14116

#14116's per-module filter does not close this specific gap. Its
conservative wrapped-lib soundness fix globs the entire
Lib.closure of any wrapped sibling that appears in the
consumer's reference set, which covers dep_lib here — so
unreached_module changes still invalidate the consumer through
the glob. The deeper filter that walks ocamldep through wrapped
libs' children to extract exactly which transitive entry modules
are reached is described as follow-on work in lib_file_deps.ml.

This PR is purely observational; no code change. The test
companions the soundness regression guards in
auto-wrapped-child-reexport.t
and wrapped-reexport-via-open-flag.t:
those assert the consumer DOES rebuild on a reached transitive
module's change (soundness preservation); this one asserts the
consumer rebuilds on an unreached transitive module's change
(precision gap).

Related: #4572, #14116

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new blackbox (cram) test case documenting the current rebuild behavior for a “wrapped sibling lib + transitive unwrapped dep” scenario where an unreached transitive module interface change still forces a consumer rebuild (i.e., captures the current precision gap in inter-library dep tracking).

Changes:

  • Add wrapped-closure-precision.t to record the current rebuild targets when editing an unreached transitive module interface.
  • Exercise the scenario via an auto-wrapped re-export library (lib_re_export) and a consumer referencing the wrapper module in source.

Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-closure-precision.t Outdated
Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-closure-precision.t Outdated
Records the precision gap that any per-module dep filter must
navigate when a wrapped sibling library's wrapper appears in a
consumer's reference set, and the consumer reaches one entry of
the wrapper's transitive [Lib.closure] via an alias chain inside
one of the wrapper's children.

Setup:
- [dep_lib] is unwrapped with two entry modules,
  [reached_module] and [unreached_module].
- [lib_re_export] is wrapped (dune auto-generates the wrapper)
  with a single child [pprint] that aliases only
  [reached_module] of [dep_lib].
- [consumer_lib] writes [Lib_re_export.Pprint.Re.x], naming
  [Lib_re_export] in source.

The consumer reaches [reached_module] through [pprint]'s alias
chain but never reaches [unreached_module]. Editing
[unreached_module]'s interface still rebuilds the consumer
on trunk (cctx-wide [-I]/[-H] glob over [dep_lib]'s objdir
fires on the [.cmi] content change). The same outcome holds for
any per-module filter that conservatively globs the
[Lib.closure] of a wrapped sibling in the reference set; only a
deeper filter that descends through wrapped libs' children to
find the alias chain can drop the dep on [unreached_module].

Companion to the soundness regression guards in
[auto-wrapped-child-reexport.t] and
[wrapped-reexport-via-open-flag.t]: those assert the consumer
DOES rebuild on a reached transitive module's change (soundness
preservation); this one asserts the consumer rebuilds on an
UNREACHED transitive module's change (precision gap).

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-test-wrapped-closure-precision branch from a2df84f to f52cc6b Compare April 28, 2026 20:19
@robinbb robinbb requested a review from Copilot April 28, 2026 20:20
@robinbb robinbb self-assigned this Apr 28, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@robinbb robinbb marked this pull request as ready for review April 28, 2026 21:12
@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Apr 29, 2026

The PR description mentions a rebuild count but the test isn't counting. Could you update the PR description since I believe that is stale?

@Alizter Alizter self-requested a review April 29, 2026 15:49
@Alizter Alizter self-assigned this Apr 29, 2026
@Alizter Alizter merged commit 52a1970 into ocaml:main Apr 29, 2026
35 checks passed
@robinbb robinbb deleted the robinbb-test-wrapped-closure-precision branch April 29, 2026 18:10
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.

3 participants