Skip to content

test: guards for wrapped-lib soundness under non-trivial wrapping#14444

Open
robinbb wants to merge 1 commit into
ocaml:mainfrom
robinbb:robinbb-test-wrapped-lib-soundness-guards
Open

test: guards for wrapped-lib soundness under non-trivial wrapping#14444
robinbb wants to merge 1 commit into
ocaml:mainfrom
robinbb:robinbb-test-wrapped-lib-soundness-guards

Conversation

@robinbb
Copy link
Copy Markdown
Collaborator

@robinbb robinbb commented May 7, 2026

Summary

Two forward-looking cram guards under
test/blackbox-tests/test-cases/per-module-lib-deps/:

  • wrapped-transition-soundness.t — soundness for (wrapped (transition ...)) consumers reaching an inner module through the wrapper alias.
  • wrapped-from-vlib-soundness.t — soundness for consumers of a vlib implementation that inherits (wrapped ...) from the vlib.

Both pass trivially on main; they fail only when future per-module narrowing of compile-rule deps drops the relevant .cmi coverage. See each test's prose header for the full soundness argument.

@robinbb robinbb self-assigned this May 7, 2026
@robinbb robinbb requested a review from Copilot May 7, 2026 22:10
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 forward-looking blackbox (cram) regression tests to guard dependency-soundness around wrapped libraries in the per-module-lib-deps suite, specifically ensuring downstream modules are invalidated when relevant inner-module interfaces change—even when type info is not carried by the wrapper .cmi.

Changes:

  • Add a cram guard for (wrapped (transition ...)) libraries to ensure consumers rebuild when an inner module’s .cmi changes, even if referenced only through the wrapper alias.
  • Add a cram guard for virtual-library implementations that inherit (wrapped ...) from the vlib, ensuring consumers rebuild when a concrete vlib module’s interface changes.

Reviewed changes

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

File Description
test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-transition-soundness.t Guards consumer rebuild soundness when accessing inner modules via a (wrapped (transition ...)) wrapper alias.
test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-from-vlib-soundness.t Guards consumer rebuild soundness when depending on a vlib implementation that inherits wrapped, ensuring concrete vlib module .cmi changes invalidate consumers.

@robinbb robinbb marked this pull request as ready for review May 7, 2026 23:34
@robinbb robinbb requested a review from Copilot May 9, 2026 02:25
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 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-transition-soundness.t Outdated
Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-transition-soundness.t Outdated
Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-from-vlib-soundness.t Outdated
robinbb added a commit to robinbb/dune that referenced this pull request May 9, 2026
Address Copilot review feedback on ocaml#14444. Under [(wrapped ...)],
the inner-module artifact is the mangled
[wrapped_lib__Inner_a.cmi]/[vlib__Helper.cmi]; the un-prefixed
[inner_a.cmi] is the transition compat shim (and no shim exists
under plain [(wrapped true)]). Naming the mangled artifact in the
prose matches the convention in wrapped-transition-incremental.t
and removes ambiguity about which .cmi the soundness story rests
on. Test logic unchanged.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb requested a review from Copilot May 9, 2026 15:51
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 2 out of 2 changed files in this pull request and generated no new comments.

@robinbb robinbb requested a review from art-w May 9, 2026 16:42
@robinbb
Copy link
Copy Markdown
Collaborator Author

robinbb commented May 9, 2026

@art-w May I bother you for a review on this? It covers an obscure corner case and I am unsure if the current tested-for behaviour (in this PR) is verifying the correct behaviour, or coincidentally harmless behaviour. Or, suggest another reviewer better suited?

robinbb added a commit to robinbb/dune that referenced this pull request May 9, 2026
Address Copilot review feedback on ocaml#14444. Under [(wrapped ...)],
the inner-module artifact is the mangled
[wrapped_lib__Inner_a.cmi]/[vlib__Helper.cmi]; the un-prefixed
[inner_a.cmi] is the transition compat shim (and no shim exists
under plain [(wrapped true)]). Naming the mangled artifact in the
prose matches the convention in wrapped-transition-incremental.t
and removes ambiguity about which .cmi the soundness story rests
on. Test logic unchanged.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit that referenced this pull request May 10, 2026
Address Copilot review feedback on #14444. Under [(wrapped ...)],
the inner-module artifact is the mangled
[wrapped_lib__Inner_a.cmi]/[vlib__Helper.cmi]; the un-prefixed
[inner_a.cmi] is the transition compat shim (and no shim exists
under plain [(wrapped true)]). Naming the mangled artifact in the
prose matches the convention in wrapped-transition-incremental.t
and removes ambiguity about which .cmi the soundness story rests
on. Test logic unchanged.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit that referenced this pull request May 10, 2026
Address Copilot review feedback on #14444. Under [(wrapped ...)],
the inner-module artifact is the mangled
[wrapped_lib__Inner_a.cmi]/[vlib__Helper.cmi]; the un-prefixed
[inner_a.cmi] is the transition compat shim (and no shim exists
under plain [(wrapped true)]). Naming the mangled artifact in the
prose matches the convention in wrapped-transition-incremental.t
and removes ambiguity about which .cmi the soundness story rests
on. Test logic unchanged.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-test-wrapped-lib-soundness-guards branch from 30ae1b6 to 0b48a07 Compare May 11, 2026 17:21
@robinbb robinbb requested review from ElectreAAS and removed request for art-w May 12, 2026 19:10
@robinbb robinbb assigned ElectreAAS and unassigned art-w May 12, 2026
@robinbb
Copy link
Copy Markdown
Collaborator Author

robinbb commented May 12, 2026

@ElectreAAS Thanks for the good review feedback on that other PR. Can you have a look at this one, too?

@robinbb robinbb force-pushed the robinbb-test-wrapped-lib-soundness-guards branch from 0b48a07 to 324abf6 Compare May 13, 2026 00:42
@robinbb robinbb requested a review from Copilot May 13, 2026 00:43
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 2 out of 2 changed files in this pull request and generated no new comments.

@Alizter Alizter self-requested a review May 14, 2026 13:33
@robinbb robinbb force-pushed the robinbb-test-wrapped-lib-soundness-guards branch from 324abf6 to cf2f7f2 Compare May 14, 2026 14:01
Two forward-looking guard files in `test/blackbox-tests/test-cases/
per-module-lib-deps/`. Each file mixes soundness cases (must keep
rebuilding) with a forward-looking pin on current per-library
filter behaviour (currently rebuilds the consumer when an
unreferenced sibling module changes; will need promotion once
per-module narrowing within a library lands):

- `wrapped-transition-soundness.t`: a consumer reaches an inner
  module of a `(wrapped (transition ...))` library through the
  wrapper alias `Wrapped_lib.Inner_a.x`. Case 1 (soundness) pins
  that the consumer rebuilds when the referenced inner module's
  interface changes — its compile-rule deps must cover
  `wrapped_lib__Inner_a.cmi` (the mangled inner-module artifact,
  not the un-prefixed transition compat shim), not only the
  wrapper's `.cmi`. Case 2 (narrowing pin) covers an unreferenced
  sibling (`inner_b`).

- `wrapped-from-vlib-soundness.t`: a consumer depends on a
  virtual-library implementation that inherits its `(wrapped ...)`
  setting from the vlib (the impl does not redeclare `wrapped`).
  Cases 1–2 (soundness) pin that the consumer rebuilds when a
  concrete vlib module (`helper`) or a virtual module
  (`virt_iface`) has its interface change — its compile-rule deps
  must cover the impl's `.cmi` directory. Case 3 (narrowing pin)
  covers an unreferenced sibling (`unused`).

The soundness cases hold trivially today via the cctx-wide
compile-rule glob over each dep library's `.cmi` directory. Future
changes that narrow compile-rule deps per-module must keep that
coverage for the referenced-module / inherited-wrapped-library
edge cases (the soundness cases); the narrowing pins will flip
when the narrowing lands and should be promoted then.

Test structure: jq regexes are anchored to the objdir
(`\.consumer\.objs/byte/consumer\.cm` and
`consumer/\.main\.eobjs/byte/`) rather than relying on dune's
internal mangling.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-test-wrapped-lib-soundness-guards branch from cf2f7f2 to e4625ea Compare May 14, 2026 14:14
@robinbb robinbb removed the request for review from ElectreAAS May 14, 2026 14:21
@robinbb robinbb assigned Alizter and unassigned ElectreAAS May 14, 2026
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.

5 participants