Skip to content

Reduce exported functions (closes #77)#80

Merged
GiggleLiu merged 11 commits intomainfrom
reduce-exports
Feb 16, 2026
Merged

Reduce exported functions (closes #77)#80
GiggleLiu merged 11 commits intomainfrom
reduce-exports

Conversation

@GiggleLiu
Copy link
Contributor

Summary

  • Internalize reduction structs and gadgets — all ReductionXToY structs changed to pub(crate), unitdiskmapping internals moved behind #[cfg(test)] re-exports
  • Add is_valid_solution() inherent methods to all 15+ problem types, replacing standalone validation functions
  • Internalize polynomial, truth_table, delete unused graph_types module
  • Slim prelude to essential items (problems, traits, solver, core types)
  • Restore accidentally-dropped PlanarGraph/BipartiteGraph VariantParam tests

Test plan

  • All existing tests pass (cargo test — 1479 tests)
  • Clippy clean
  • No useful tests dropped (audited all 7 removed tests — 2 gaps found and restored)
  • Examples still compile and run with explicit imports

Closes #77

🤖 Generated with Claude Code

GiggleLiu and others added 10 commits February 16, 2026 23:48
Remove public re-exports of ~30 ReductionXToY structs, 6 gadget
functions, BoolVar, LogicGadget, and JSON serialization types
(EdgeJson, NodeJson, ReductionGraphJson) from rules/mod.rs. Users
interact with reductions via the ReduceTo trait or ReductionGraph,
never referencing these structs by name.

Also remove unused ReductionColoringToILP type alias and suppress
dead_code warnings on LogicGadget fields only read in tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change internal type re-exports (CopyLine, MappingGrid, CellState,
Pattern, etc.) from pub to pub(crate) in unitdiskmapping/mod.rs.
Change alpha_tensor and pathdecomposition modules to pub(crate).

Add #[cfg(test)] guards on re-exports only needed by unit tests.
Add #[doc(hidden)] _internal module for the export_mapping_stages
example which needs these types.

Keep ksg, triangular modules and GridKind/MappingResult as pub.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…es module

- Change polynomial and truth_table modules from pub to pub(crate)
  since they are only used internally via crate:: imports.
- Delete graph_types.rs and its unit test file (zero internal imports,
  confirmed by codebase audit; actual graph types live in topology/).
- Remove truth_table integration tests from tests/suites/reductions.rs
  (equivalent coverage exists in src/unit_tests/truth_table.rs).
- Remove doc example from TruthTable since the module is now internal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add public is_valid_solution(&self, config: &[usize]) -> bool methods to
all graph problem types, delegating to existing private validation helpers.
Also add cut_size method to MaxCut for computing partition cut sizes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add public is_valid_solution methods to MaximumSetPacking,
MinimumSetCovering, BicliqueCover, CircuitSAT, and Factoring.
Each delegates to existing validation logic. PaintShop already
has count_switches and BMF is skipped per design.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change standalone validation free functions (is_independent_set,
is_vertex_cover, is_clique, etc.) from pub to pub(crate) with #[cfg(test)]
for test-only functions. Functions still used in non-test code
(is_valid_coloring, is_hamiltonian_cycle, cut_size) remain pub(crate)
without #[cfg(test)].

- Change 17 validation functions from pub to pub(crate)
- Add #[cfg(test)] to 14 functions only used in tests
- Remove validation function re-exports from graph/set/specialized mod.rs
- Make submodules pub(crate) for crate-internal test access
- Update graph_models.rs imports to use full module paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change these utility functions from pub to pub(crate) with #[cfg(test)]
since they are only used in unit tests. This reduces the public API
surface of the config module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove from prelude: config utilities, registry types, variant types,
ILP/optimization internals, NumericSize, and WeightElement. These items
remain accessible via their full module paths.

Add explicit imports to 16 examples, 2 integration test files that
previously relied on the broader prelude:
- ILP type: 13 examples + 1 test file
- K3/K2 variant types: 7 examples + 2 test files
- LinearConstraint/ObjectiveSense: 1 example + 1 test file

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These tests were dropped when graph_types.rs was deleted but had no
equivalent coverage elsewhere. Added them to variant.rs where similar
graph type VariantParam tests already exist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.33%. Comparing base (eb92e0a) to head (4b87242).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #80      +/-   ##
==========================================
+ Coverage   96.13%   96.33%   +0.20%     
==========================================
  Files         193      193              
  Lines       26585    26682      +97     
==========================================
+ Hits        25557    25704     +147     
+ Misses       1028      978      -50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Cover all 15 new public methods with both valid and invalid cases:
- 14 is_valid_solution tests across all problem types
- 1 cut_size method test for MaxCut

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GiggleLiu GiggleLiu merged commit 7bbd90b into main Feb 16, 2026
5 checks passed
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.

Reduce exported functions

1 participant