Commit f75a28c
Finalize structural example database (#647)
* save
* docs: add variant default resolution design
* save
* docs: refine CLI path behavior in variant plan
* refactor(example-db): make rule builders canonical
Remove the legacy exporter bridge (LegacyRuleEntry, legacy_rule! macro,
LEGACY_RULES, temp-dir helpers, env-var guards, stdout silencing, and
build_legacy_rule) from src/example_db/mod.rs. The in-memory builders in
rule_builders.rs are now the only rule source with no filesystem round-trip.
Add crate-level integration tests proving canonical rule examples carry
full problem JSON (MVC→MIS graph fields, SAT→KColoring clauses/graph).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test(cli): round-trip canonical examples through solve
Add end-to-end tests proving that `pred create --example` output can be
fed directly to `pred solve --solver brute-force` for both model examples
(MIS/SimpleGraph/i32) and rule examples (MVC→MIS).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(example-db): finalize structural example database
Add structural invariant tests:
- unique keys for both rule and model databases
- count assertions (42 rules, 28 models)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* update plan
* docs: add variant implementation plan
* test: add failing tests for VariantSpec, default_variant_for, and export normalization
Add stub types and methods with failing tests that establish the contract
for the variant default resolution feature:
- VariantSpec type in src/variant.rs with try_from_pairs, normalize (no-op),
and is_default (always false) stubs
- ReductionGraph::default_variant_for stub (always returns None)
- 13 new tests: 8 pass (basic construction), 5 fail (normalization, defaults)
- Format fixes from cargo fmt
Failing tests (to be made green in Tasks 2-3):
- variant_spec_normalizes_empty_graph_to_simple_graph
- variant_spec_is_default_for_default_values
- default_variant_for_mis_uses_declared_default
- default_variant_for_sat_returns_empty
- export_variant_to_map_normalizes_empty_graph
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add explicit variant defaults
Implement `default` metadata in `declare_variants!` macro and `VariantSpec`:
- Extend `declare_variants!` parsing to accept optional `default` keyword
- Add `is_default: bool` to `VariantEntry` for runtime tracking
- Implement backwards-compatible default resolution: if no `default` marker
is present, the first entry is implicitly the default
- Reject multiple `default` markers for the same problem at compile time
- Implement `VariantSpec::normalize()` to fill empty graph with "SimpleGraph"
- Implement `VariantSpec::is_default()` to detect default dimension values
- Add `try_from_map`, `into_map`, `update_dimension` to `VariantSpec`
- Populate `default_variants` in `ReductionGraph::new()` from inventory
- Implement `ReductionGraph::default_variant_for()` using stored defaults
- Normalize empty graph values in `export::variant_to_map()`
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: mark default problem variants
Add explicit `default` keyword to every `declare_variants!` block across
all 38 model files, following the selection rules:
- Graph families: prefer SimpleGraph
- Weighted/unweighted: prefer One (unweighted) when available
- K-families: prefer KN as generic default
- Integer-vs-float without One: prefer integer variant
- Single-variant problems: mark the only variant
Add regression tests for MinimumVertexCover, QUBO, and KSatisfiability
default variant resolution.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: unify CLI problem resolution with exact-node semantics
Switch CLI commands to use declared default variants for bare problem
names instead of searching across all variants. Add capped multi-path
support (--max-paths flag) to prevent unbounded enumeration.
Key changes:
- Add parse_problem_type() for type-level show command (rejects slashes)
- Add resolve_problem_ref() shared resolver using declared defaults
- Show command now marks default variant with (default) annotation
- Path/neighbors/reduce commands use exact default variant nodes
- Add find_paths_up_to() capped path enumeration to ReductionGraph
- Multi-path JSON output uses structured envelope with truncation metadata
- Directory output includes manifest.json
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: align MCP tools and CLI docs with exact-node variant semantics
Update MCP server tools to use the same resolver semantics as CLI:
- show_problem_inner: use parse_problem_type (rejects slash specs),
add is_default field to variant JSON output
- neighbors_inner: use resolve_problem_ref for exact default resolution
- find_path_inner: use resolve_problem_ref, add max_paths param,
use find_paths_up_to with truncation detection, return structured
envelope {paths, truncated, returned, max_paths} for all=true
- create_problem_inner: use resolve_problem_ref for name resolution
- reduce_inner: use resolve_problem_ref for target resolution
Add new MCP tests: slash spec rejection, is_default marking,
structured envelope validation. Update docs with type-level show
semantics, --max-paths flag, and default variant resolution note.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: require exact source+target variant match in find_best_entry
Remove the unsafe name-only fallback from find_best_entry() that could
return overhead for the wrong variant. Now both source and target
variants must match exactly. Update lookup_overhead() to pass the
target variant through instead of ignoring it. Fix direct_overhead()
in rule_builders to fall back to default variants when a concrete
variant (e.g. K3) has no registered reduction entry.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* style: fix formatting in MCP tools and tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* grand clean up
* feat(registry): add core dynamic problem types
Add DynProblem trait and LoadedDynProblem wrapper for type-erased
problem dispatch via the registry.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(macros): add transitional solver-kind dispatch generation
Extend declare_variants! to accept optional `opt` and `sat` markers
that generate factory, serialize_fn, and solve_fn dispatch metadata
in VariantEntry. Legacy entries without markers emit None for these
fields during the transition period.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(registry): register load serialize and solve dispatch metadata
Annotate all declare_variants! blocks with opt/sat solver kind markers.
Add load_dyn, serialize_any, and find_variant_entry registry helpers
with integration tests for exact-match lookup, round-trip serialization,
and brute-force solving.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(registry): require solver kind in variant registrations
Remove transitional Option wrappers from VariantEntry dispatch fields.
The parser now requires opt or sat markers — legacy entries without
solver kind are rejected at compile time.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(cli): use registry-backed dynamic problem dispatch
Replace CLI-local DynProblem trait, match tables, and helper functions
with the core registry's load_dyn and serialize_any. Add SAT solve
regression test.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test(dispatch): finalize registry-backed dispatch verification
Add SolveFn type alias to fix clippy::type_complexity warnings.
Format files to pass fmt check.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* update
* feat(registry): add problem type catalog and typed refs
Introduce ProblemType catalog with alias lookup, VariantDimension for
schema-validated variant dimensions, and typed ProblemRef for catalog-
backed variant resolution. Extend ProblemSchemaEntry with display_name,
aliases, and dimensions fields (populated for MIS, placeholders for rest).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(cli): resolve problem specs through the catalog
Add catalog-backed alias resolution (tries ProblemSchemaEntry aliases
first, falls back to legacy ALIASES table). Add resolve_catalog_problem_ref
for schema-only validation without graph reachability. Update shell
completion to include catalog aliases.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(models): declare catalog metadata alongside schemas
Populate display_name, aliases, and dimensions for all 38 problem
models. Add invariant tests: display_name non-empty, aliases globally
unique, dimension defaults valid, catalog covers all declared variants,
and catalog defaults match reduction graph defaults.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* update
* feat(rules): add stable auto-generated rule IDs to reduction entries
Each ReductionEntry now has a unique rule_id auto-generated from
source/target type names and generic arguments. The proc macro
computes IDs at compile time (e.g., minimumvertexcover_to_maximumindependentset_simplegraph_i32).
Optional explicit id = "..." attribute supported for overrides.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* save
* refactor(example-db): finalize per-module specs with invariant tests
Add uniqueness tests for model and rule example spec IDs. Clean up
remaining rule_builders.rs to delegate to per-module specs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(core): add Problem::problem_type() catalog bridge method
Adds a default method on the Problem trait that bridges to the
catalog registry, giving typed access to display names, aliases,
and variant dimensions. Problem::NAME is preserved as the zero-cost
compile-time source of truth; the bridge adds runtime catalog access.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove unused imports and suppress dead_code warnings in specs
The `id` field on ModelExampleSpec/RuleExampleSpec is only read in test
code, so allow(dead_code) is appropriate. Also drops unused Minimize
and MinimizeSteps imports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* update
* update
* update
* test: improve coverage for export, variant, analysis, and registry
- Add tests for ProblemSide::from_problem, ModelExample::from_problem,
default_expr, examples_output_dir env override, write_rule/model_example_to
- Add error-path tests for find_rule/model_example (not-found)
- Add VariantSpec coverage: try_from_map, into_map, update_dimension,
normalize without graph key, is_default edge cases
- Add analysis tests: missing_proof_chains filter, connectivity components,
isolated problem variant info
- Fix clippy type_complexity warning in registry test (extract EndpointKey alias)
- Remove deprecated id attribute from reduction macro
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: remove ephemeral plan files from PR
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* update
* docs: update CLAUDE.md model lists and trait hierarchy
- Add 10 missing graph models (GraphPartitioning, HamiltonianPath,
IsomorphicSpanningTree, MinFeedbackArcSet, MinFeedbackVertexSet,
MinSumMulticenter, OptimalLinearArrangement, PartitionIntoTriangles,
RuralPostman, SubgraphIsomorphism)
- Add 5 missing misc models (FlowShopScheduling, Knapsack,
LongestCommonSubsequence, ShortestCommonSupersequence, SubsetSum)
- Add problem_type() to Problem trait hierarchy
- Update Problem Names to include all current types
- Add specs.rs to example_db documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: replace hardcoded model/rule lists with CLI commands in CLAUDE.md
Point agents to `pred list` and `pred show <name>` instead of
maintaining exhaustive lists that go stale.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(cli): add `pred list --rules` to enumerate all reduction rules
Shows source, target, and overhead for every registered primitive
reduction. Supports --json output. Replaces the need to maintain
hardcoded rule lists in documentation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(cli): add complexity to `pred list`, improve `--rules` format, upgrade rmcp to 1.2
- `pred list`: add Complexity column showing best-known complexity (Big O)
for the default variant of each problem type
- `pred list --rules`: show overhead fields on separate continuation lines
instead of a single wide column; JSON overhead is now an array
- Upgrade rmcp from 0.16 to 1.2: migrate MCP server and prompts to
builder patterns required by #[non_exhaustive] structs
- Add merge conflict guidance for skill changes to review-pipeline skill
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(cli): improve `pred list` and `pred list --rules` table formatting
- `pred list`: expand rows per variant (show variant slash notation,
complexity, and default marker *) instead of aggregating per problem
- `pred list --rules`: fix ANSI padding (pad plain text first, then
colorize) so columns align correctly; multi-field overhead uses
continuation lines
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: remove 3SAT alias, use KSAT/K3 instead
3SAT was a type-level alias for KSatisfiability which was confusing
because it displayed next to the KN default variant. Replace all
references with KSAT (the type alias) and KSAT/K3 (the explicit
variant). Remove the special-case resolution code.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* perf: remove mcp from default CLI features for faster dev builds
MCP (rmcp + tokio + schemars + tracing) adds ~14s to clean builds.
Move it out of default features so `cargo build` and `make cli` are
fast. MCP is still available via `--features mcp` or `--features all`.
CI already uses explicit `--features ilp-highs` (no mcp).
MCP tests use `make mcp-test` which passes `--features mcp`.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add `make mcp` target for CLI with MCP support
`make cli` stays fast (no MCP). Use `make mcp` to build with
MCP server support when needed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: remove unused mut from variant_values
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* revert: restore single-line overhead in `pred list --rules`
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix cli
* fix tests
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 60ec662 commit f75a28c
189 files changed
Lines changed: 7433 additions & 7529 deletions
File tree
- .claude
- skills
- add-model
- add-rule
- final-review
- issue-to-pr
- review-implementation
- review-pipeline
- write-model-in-paper
- write-rule-in-paper
- .github/workflows
- docs
- agent-profiles
- paper
- src
- examples
- problemreductions-cli
- src
- commands
- mcp
- tests
- problemreductions-macros/src
- src
- example_db
- models
- algebraic
- formula
- graph
- misc
- set
- registry
- rules
- unit_tests
- models
- algebraic
- formula
- set
- registry
- rules
- tests/suites
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| |||
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
114 | | - | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| |||
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
157 | 165 | | |
158 | 166 | | |
159 | 167 | | |
160 | 168 | | |
161 | 169 | | |
162 | 170 | | |
163 | | - | |
| 171 | + | |
| 172 | + | |
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
| |||
194 | 203 | | |
195 | 204 | | |
196 | 205 | | |
197 | | - | |
| 206 | + | |
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
202 | 211 | | |
203 | 212 | | |
204 | | - | |
| 213 | + | |
| 214 | + | |
205 | 215 | | |
206 | 216 | | |
207 | 217 | | |
| |||
254 | 264 | | |
255 | 265 | | |
256 | 266 | | |
| 267 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
96 | | - | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
104 | | - | |
| 110 | + | |
105 | 111 | | |
106 | 112 | | |
107 | 113 | | |
| |||
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
115 | | - | |
| 121 | + | |
116 | 122 | | |
117 | | - | |
| 123 | + | |
118 | 124 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| |||
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
142 | 158 | | |
143 | 159 | | |
144 | 160 | | |
| |||
233 | 249 | | |
234 | 250 | | |
235 | 251 | | |
236 | | - | |
237 | | - | |
| 252 | + | |
| 253 | + | |
238 | 254 | | |
239 | 255 | | |
240 | 256 | | |
241 | 257 | | |
242 | 258 | | |
| 259 | + | |
243 | 260 | | |
244 | 261 | | |
0 commit comments