You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .claude/CLAUDE.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ Rust library for NP-hard problem reductions. Implements computational problems w
12
12
-[write-model-in-paper](skills/write-model-in-paper/SKILL.md) -- Write or improve a problem-def entry in the Typst paper. Covers formal definition, background, example with visualization, and algorithm list.
13
13
-[write-rule-in-paper](skills/write-rule-in-paper/SKILL.md) -- Write or improve a reduction-rule entry in the Typst paper. Covers complexity citation, self-contained proof, detailed example, and verification.
14
14
-[release](skills/release/SKILL.md) -- Create a new crate release. Determines version bump from diff, verifies tests/clippy, then runs `make release`.
15
+
-[meta-power](skills/meta-power/SKILL.md) -- Batch-resolve all open `[Model]` and `[Rule]` issues autonomously: plan, implement, review, fix CI, merge — in dependency order (models first).
15
16
16
17
## Commands
17
18
```bash
@@ -26,7 +27,7 @@ make mdbook # Build and serve mdBook with live reload
26
27
make paper # Build Typst paper (runs examples + exports first)
27
28
make coverage # Generate coverage report (>95% required)
make rust-export # Generate Rust mapping JSON exports
30
+
make rust-export # Generate Julia parity test data (mapping stages)
30
31
make export-schemas # Regenerate problem schemas JSON
31
32
make qubo-testdata # Regenerate QUBO ground truth JSON
32
33
make clean # Clean build artifacts
@@ -90,6 +91,8 @@ enum Direction { Maximize, Minimize }
90
91
```
91
92
92
93
### Key Patterns
94
+
-`variant_params!` macro implements `Problem::variant()` — e.g., `crate::variant_params![G, W]` for two type params, `crate::variant_params![]` for none (see `src/variant.rs`)
95
+
-`declare_variants!` proc macro registers concrete type instantiations with best-known complexity — must appear in every model file (see `src/models/graph/maximum_independent_set.rs`). Variable names in complexity strings are validated at compile time against actual getter methods.
93
96
- Problems parameterized by graph type `G` and optionally weight type `W` (problem-dependent)
94
97
-`ReductionResult` provides `target_problem()` and `extract_solution()`
95
98
-`Solver::find_best()` → `Option<Vec<usize>>` for optimization problems; `Solver::find_satisfying()` → `Option<Vec<usize>>` for `Metric = bool`
@@ -101,7 +104,7 @@ enum Direction { Maximize, Minimize }
101
104
-`NumericSize` supertrait bundles common numeric bounds (`Clone + Default + PartialOrd + Num + Zero + Bounded + AddAssign + 'static`)
102
105
103
106
### Overhead System
104
-
Reduction overhead is expressed using `Expr` AST (in `src/expr.rs`) with the `#[reduction]` macro:
107
+
Reduction overhead is expressed using `Expr` AST (in `src/expr.rs`) with the `#[reduction]` macro. The `overhead` attribute is **required** — omitting it is a compile error:
105
108
```rust
106
109
#[reduction(overhead = {
107
110
num_vertices ="num_vertices + num_clauses",
@@ -110,9 +113,14 @@ Reduction overhead is expressed using `Expr` AST (in `src/expr.rs`) with the `#[
110
113
implReduceTo<Target> forSource { ... }
111
114
```
112
115
- Expression strings are parsed at compile time by a Pratt parser in the proc macro crate
116
+
- Variable names are validated against actual getter methods on the source type — typos cause compile errors
113
117
- Each problem type provides inherent getter methods (e.g., `num_vertices()`, `num_edges()`) that the overhead expressions reference
114
118
-`ReductionOverhead` stores `Vec<(&'static str, Expr)>` — field name to symbolic expression mappings
Copy file name to clipboardExpand all lines: .claude/skills/add-model/SKILL.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,25 @@ Key decisions:
84
84
-**Weight management:** use inherent methods (`weights()`, `set_weights()`, `is_weighted()`), NOT traits
85
85
-**`dims()`:** returns the configuration space dimensions (e.g., `vec![2; n]` for binary variables)
86
86
-**`evaluate()`:** must check feasibility first, then compute objective
87
+
-**`variant()`:** use the `variant_params!` macro — e.g., `crate::variant_params![G, W]` for `Problem<G, W>`, or `crate::variant_params![]` for problems with no type parameters. Each type parameter must implement `VariantParam` (already done for standard types like `SimpleGraph`, `i32`, `One`). See `src/variant.rs`.
88
+
89
+
## Step 2.5: Register variant complexity
90
+
91
+
Add `declare_variants!` at the bottom of the model file (after the trait impls, before the test link). Each line declares a concrete type instantiation with its best-known worst-case complexity:
- The complexity string references the getter method names from Step 1.5 (e.g., `num_vertices`) — variable names are validated at compile time against actual getters, so typos cause compile errors
101
+
- One entry per supported `(graph, weight)` combination
102
+
- The string is parsed as an `Expr` AST — supports `+`, `-`, `*`, `/`, `^`, `exp()`, `log()`, `sqrt()`
103
+
- Use only concrete numeric values (e.g., `"1.1996^num_vertices"`, not `"(2-epsilon)^num_vertices"`)
104
+
- A compiled `complexity_eval_fn` is auto-generated alongside the symbolic expression
105
+
- See `src/models/graph/maximum_independent_set.rs` for the reference pattern
87
106
88
107
## Step 3: Register the model
89
108
@@ -146,5 +165,6 @@ Then run the [review-implementation](../review-implementation/SKILL.md) skill to
146
165
| Missing `#[path]` test link | Add `#[cfg(test)] #[path = "..."] mod tests;` at file bottom |
147
166
| Wrong `dims()`| Must match the actual configuration space (e.g., `vec![2; n]` for binary) |
148
167
| Not registering in `mod.rs`| Must update both `<category>/mod.rs` and `models/mod.rs`|
168
+
| Forgetting `declare_variants!`| Required for variant complexity metadata used by the paper's auto-generated table |
149
169
| Forgetting CLI dispatch | Must add match arms in `dispatch.rs` (`load_problem` + `serialize_any_problem`) |
150
170
| Forgetting CLI alias | Must add lowercase entry in `problem_name.rs``resolve_alias()`|
Invoke the `/write-rule-in-paper` skill to write the reduction-rule entry in `docs/paper/reductions.typ`. That skill covers the full authoring process: complexity citation, self-contained proof, detailed worked example, and verification checklist.
133
133
134
-
## Step 6: Regenerate graph and verify
134
+
## Step 6: Regenerate exports and verify
135
135
136
136
```bash
137
-
cargo run --example export_graph # Update reduction_graph.json
138
-
make test clippy # Must pass
137
+
cargo run --example export_graph # Update reduction_graph.json
138
+
cargo run --example export_schemas # Update problem schemas
139
+
make test clippy # Must pass
139
140
```
140
141
141
142
Then run the [review-implementation](../review-implementation/SKILL.md) skill to verify all structural and semantic checks pass.
Copy file name to clipboardExpand all lines: .claude/skills/issue-to-pr/SKILL.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,9 +81,14 @@ Include the concrete details from the issue (problem definition, reduction algor
81
81
82
82
Create a pull request with only the plan file.
83
83
84
+
**Pre-flight checks** (before creating the branch):
85
+
1. Verify clean working tree: `git status --porcelain` must be empty. If not, STOP and ask user to stash or commit.
86
+
2. Check if branch already exists: `git rev-parse --verify issue-<number>-<slug> 2>/dev/null`. If it exists, switch to it with `git checkout` (no `-b`) instead of creating a new one.
0 commit comments