Skip to content

gen_exports: unfollowed using-directives must be declared (skip-directive); detail groups of #2 confirmed droppable - #10

Merged
ZheFeng7110 merged 3 commits into
mcpplibs:mainfrom
ZheFeng7110:fix/skipped-directive-reasons
Nov 29, 2026
Merged

ZheFeng7110 merged 3 commits into
mcpplibs:mainfrom
ZheFeng7110:fix/skipped-directive-reasons

Conversation

@ZheFeng7110

Copy link
Copy Markdown
Collaborator

Follows #9. Part of #2: the second acceptance criterion, i.e. the detail-namespace groups and suggested direction 2 ("record the reason in skipped.txt, do not drop silently"). The unanalysed small groups and the reachable-export check in verify-scripts are still open.

Problem

collect_injections follows a using namespace only in the ADL-barrier shape, where the target is nested in the directive's own namespace. Every other directive was skipped without a trace. #2 listed three groups lost this way, marked "detail, probably fine to drop, needs confirming":

names namespace directive
356 boost::numeric::ublas::detail ublas/matrix.hpp, triangular.hpp: using namespace boost::numeric::ublas;
355 boost::serialization::cpp_int_detail multiprecision/cpp_int/serialize.hpp: using namespace boost::multiprecision; (+ ::backends)
55 boost::sort::blk_detail sort/block_indirect_sort/blk_detail/block.hpp: using namespace boost::sort::common;

Confirmation: the three groups can be dropped

  • Every skipped directive. A cold full generation with the skip branch instrumented found 12 sites in 10 (library, namespace) pairs across the 116 libraries. Besides the three above and dll::fs (dll: boost::dll::fs follows boost::filesystem (policy republish), smoke test asserts it #9), they are: icl Interval_Set / Interval_Map → icl::segmental, poly_collection::common_impl → poly_collection::detail, accumulators numeric::functional / accumulators::impl → numeric::operators, and cobalt::this_coro → asio::this_coro.
  • Upstream spellings. I grepped every qualified spelling through these namespaces in upstream/boost/boost (headers, macro bodies) and upstream/boost/libs (tests, examples) and matched each one against the generated .inc files:
    • Every spelling names a member declared in that namespace itself, and all of those are exported directly.
    • None reaches a name only through the directive. The two ublas::detail exceptions: recursive is a nested namespace (recursive::mtv is exported), and make_lambda appears only in a comment.
    • No code opens these namespaces with its own using namespace.
    • Upstream's comment on namespace numeric::operators {} reads "For using directives".
  • Template instantiation is unaffected. Unqualified lookup in GMF headers happens at the definition, where the directive is visible; exports only decide what an importer can spell.
  • cobalt is the one public spelling (cobalt::this_coro::executor). It is already handled by [[cobalt.extra]].

Change

  • New policy rule [[<lib>.skip-directive]] (namespace, reason), checked by check_skipped_directives:
    • Generation now fails if any non-ADL-barrier directive in a library's own headers is not declared, either as republish or as skip-directive. The error names the directive, its target and both options.
    • Also errors: an entry that matches no unfollowed directive (stale, an ADL barrier, or another library's header), and an entry that is also a republish.
    • Each entry is listed in skipped.txt as <lib> skip-directive <namespace> -- <reason>; the file header mentions this now.
    • Cache: the entries are part of the library's policy digest, so a cache hit replays them and needs no re-check.
  • Nine entries in tools/export_policy.toml: accumulators ×2, cobalt, icl ×2, multiprecision, numeric, poly_collection, sort. Each reason states where the directive is and what it is for, the public spelling, and the result of the upstream check. The detail groups also give the name count that following them would add.
  • Output: 9 new lines in skipped.txt. No .inc / .deps file changes.
  • tools/tests/test_gen_exports_skip_directive.py: 8 tests covering the cases above.
  • Docs: docs/architecture{,.zh}.md and the design record .agents/docs/2026-11-28-skip-directive-design.md. The record also covers the rejected options: documenting only the three detail groups, auto-allowing by a detail substring, and switching cobalt to republish, which would add five asio helper types to its surface.

Side finding (not addressed)

accumulators' GMF includes boost/accumulators/numeric/functional/vector.hpp and its valarray / complex siblings. Even so, no module exports the operator templates in boost::numeric::operators (operator/(std::vector…) etc.). This is unrelated to directives; it is noted in the design record for a separate look.

Verified locally

  • gen_exports.py --check --no-cache (cold, every library checked) and a cached --check; gen_features.py --check; tools/ci/test_coverage.py check; tools/doc-tools/check_docs.py and gen_index.py --check.
  • tools/tests: 57 tests pass.
  • Negative path on real data: with the sort entry removed, generation fails with error: sort: `using namespace boost::sort::common;` in boost::sort::blk_detail (...) is not followed: declare [[sort.republish]] ... else [[sort.skip-directive]] ....
  • No module was rebuilt, since the module outputs are byte-identical.
  • Rebased onto main after dll: boost::dll::fs follows boost::filesystem (policy republish), smoke test asserts it #9's squash merge: the merge commit's tree is identical to dll: boost::dll::fs follows boost::filesystem (policy republish), smoke test asserts it #9's head, so the checks above still apply; tools/tests and the docs checks were rerun on the rebased branch.

…kip-directive)

collect_injections follows a using-directive only in the ADL-barrier shape;
any other directive dropped every name it makes visible without a trace.
check_skipped_directives now requires each such directive in a library's own
headers to be declared, as a republish or as a skip-directive with its
reason, and rejects stale entries. Declared skips are listed in skipped.txt.
…-directive)

The detail groups of #2 (ublas::detail, serialization::cpp_int_detail,
sort::blk_detail) and the other directives the generator skips (icl
Interval_Set / Interval_Map, poly_collection::common_impl, accumulators
numeric::functional / impl, cobalt::this_coro, covered by its extra). No
Boost header, macro, test or example spells a name through any of them.
Only skipped.txt changes; no .inc / .deps output moves.
@ZheFeng7110
ZheFeng7110 merged commit e2f10c6 into mcpplibs:main Nov 29, 2026
20 checks passed
@ZheFeng7110
ZheFeng7110 deleted the fix/skipped-directive-reasons branch November 29, 2026 11:21
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