Fix #401: [Model] ComparativeContainment#662
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #662 +/- ##
==========================================
+ Coverage 97.09% 97.11% +0.02%
==========================================
Files 292 294 +2
Lines 38984 39220 +236
==========================================
+ Hits 37851 38088 +237
+ Misses 1133 1132 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new ComparativeContainment set-based satisfaction problem to the core library and wires it through the CLI, example DB, and generated documentation so it can be created/serialized consistently like existing models.
Changes:
- Introduces the
ComparativeContainment<W>model (schema registration, variants, example-db spec, and unit tests). - Extends
pred createwith new flags (--r-sets/--s-sets/--r-weights/--s-weights) and help formatting tweaks. - Regenerates example fixtures and docs artifacts (schemas + reduction graph) and adds a paper entry.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/unit_tests/trait_consistency.rs | Adds the new model to the trait-consistency smoke test suite. |
| src/unit_tests/models/set/comparative_containment.rs | New unit tests covering creation, evaluation, brute-force solving, and serialization. |
| src/models/set/mod.rs | Registers and re-exports the new set model; adds example-db specs hook. |
| src/models/set/comparative_containment.rs | Implements the ComparativeContainment model, schema entry, variants, and example-db spec. |
| src/models/mod.rs | Re-exports ComparativeContainment at the models module level. |
| src/lib.rs | Re-exports ComparativeContainment via the crate prelude. |
| src/example_db/fixtures/examples.json | Adds a canonical model example and updates regenerated fixtures. |
| problemreductions-cli/tests/cli_tests.rs | Adds CLI tests for creating ComparativeContainment instances across weight variants. |
| problemreductions-cli/src/commands/create.rs | Adds ComparativeContainment creation logic; generalizes set/weight parsing helpers; improves help flag naming. |
| problemreductions-cli/src/cli.rs | Adds new create flags for ComparativeContainment and updates CLI help banner. |
| docs/src/reductions/reduction_graph.json | Regenerates reduction graph nodes/indices including ComparativeContainment variants. |
| docs/src/reductions/problem_schemas.json | Regenerates exported schema list to include ComparativeContainment. |
| docs/paper/reductions.typ | Adds Comparative Containment entry to the paper (definition + example). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// Create a new instance with explicit weights. | ||
| pub fn with_weights( | ||
| universe_size: usize, | ||
| r_sets: Vec<Vec<usize>>, | ||
| s_sets: Vec<Vec<usize>>, | ||
| r_weights: Vec<W>, | ||
| s_weights: Vec<W>, | ||
| ) -> Self { | ||
| assert_eq!( | ||
| r_sets.len(), | ||
| r_weights.len(), | ||
| "number of R sets and R weights must match" | ||
| ); | ||
| assert_eq!( | ||
| s_sets.len(), | ||
| s_weights.len(), | ||
| "number of S sets and S weights must match" | ||
| ); | ||
| validate_set_family("R", universe_size, &r_sets); | ||
| validate_set_family("S", universe_size, &s_sets); |
| self.valid_config(config) | ||
| && config | ||
| .iter() | ||
| .enumerate() | ||
| .all(|(element, &selected)| selected == 0 || set.contains(&element)) |
…01-comparative-containment # Conflicts: # docs/paper/reductions.typ # docs/src/reductions/reduction_graph.json # problemreductions-cli/src/commands/create.rs # problemreductions-cli/tests/cli_tests.rs # src/lib.rs # src/models/mod.rs # src/unit_tests/trait_consistency.rs
…01-comparative-containment # Conflicts: # docs/src/reductions/problem_schemas.json # docs/src/reductions/reduction_graph.json # problemreductions-cli/src/cli.rs # problemreductions-cli/src/commands/create.rs # src/example_db/fixtures/examples.json # src/unit_tests/trait_consistency.rs
Agentic Review ReportStructural CheckStructural Review: model ComparativeContainmentStructural Completeness
Build Status
Semantic Review
Issue Compliance
Summary
Quality CheckDesign Principles
HCI (CLI/MCP changed)
Test Quality
IssuesImportant (Should Fix):
Minor (Nice to Have):
Agentic Feature TestsSummaryOverall verdict: PASS — no issues found. All CLI workflows function correctly from a downstream user's perspective. Tests Performed
Semantic Correctness VerificationManually verified
Issues FoundNone. The implementation is complete and correct from a user perspective. Generated by review-pipeline |
- evaluate() now delegates to is_valid_solution() instead of duplicating the r_weight_sum >= s_weight_sum comparison - Add missing #[should_panic] test for S-family i32 nonpositive weights Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Follow-up items (recorded during final review):
|
…e coverage - Replace `validate_weight_family` dyn Any downcasting with WeightElement trait: use `weight.to_sum() > zero` via `partial_cmp`, which correctly rejects non-positive and NaN values for all weight types - Remove `use std::any::Any` import - Tighten impl block bound from `W: 'static` to `W: WeightElement` - Add direct r_weight_sum/s_weight_sum test with value assertions - Add S-family weight count mismatch should_panic test - Update should_panic messages to match unified validation error format Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…elper The empty_args() helper in create.rs tests constructs CreateArgs manually and was missing the r_sets/s_sets/r_weights/s_weights fields added by this PR, causing a compilation error in CI coverage builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Fixes #401