Skip to content

Commit e27ef70

Browse files
GiggleLiuclaude
andcommitted
Clean up repo: deduplicate docs, remove stale files, fix configs
- Slim CLAUDE.md (193→87 lines): extract duplicated content into rule files - Add rules/documentation.md for Typst paper patterns - Update rules/adding-reductions.md to use #[reduction] macro - Delete 21 stale plan files in docs/plans/ (-12K lines) - Remove Cargo.lock from tracking (library crate) - Consolidate duplicate coverage CI into ci.yml, delete coverage.yml - Fix Makefile compare target paths (tests/julia/ → tests/data/) - Fix book.toml repo URL (liujinguo → CodingThrust) - Gitignore .claude/settings.local.json and Cargo.lock Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e22297d commit e27ef70

31 files changed

Lines changed: 82 additions & 13547 deletions

.claude/CLAUDE.md

Lines changed: 9 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ make test clippy export-graph # Must pass before PR
2626
- `src/traits.rs` - `Problem`, `ConstraintSatisfactionProblem` traits
2727
- `src/rules/traits.rs` - `ReduceTo<T>`, `ReductionResult` traits
2828
- `src/registry/` - Compile-time reduction metadata collection
29-
- `src/unit_tests/` - Unit test files (extracted from inline `mod tests` blocks via `#[path]`)
30-
- `tests/main.rs` - User-facing integration tests only (modules in `tests/suites/`)
29+
- `src/unit_tests/` - Unit test files (mirroring `src/` structure, referenced via `#[path]`)
30+
- `tests/main.rs` - Integration tests (modules in `tests/suites/`)
3131

3232
### Trait Hierarchy
3333

@@ -56,80 +56,11 @@ ConstraintSatisfactionProblem : Problem (extension for CSPs)
5656
└── ... (default methods: is_satisfied, compute_objective)
5757
```
5858

59-
### Problem Implementations
60-
61-
| Problem | `Problem` | `ConstraintSatisfactionProblem` |
62-
|---------|:---------:|:-------------------------------:|
63-
| IndependentSet |||
64-
| VertexCovering |||
65-
| DominatingSet |||
66-
| Matching |||
67-
| MaxCut |||
68-
| Coloring |||
69-
| Satisfiability |||
70-
| KSatisfiability |||
71-
| SetPacking |||
72-
| SetCovering |||
73-
| SpinGlass |||
74-
| QUBO |||
75-
| ILP |||
76-
| CircuitSAT |||
77-
| Factoring |||
78-
7959
### Key Patterns
8060
- Problems parameterized by weight type `W` and graph type `G`
8161
- `ReductionResult` provides `target_problem()` and `extract_solution()`
8262
- Graph types: SimpleGraph, GridGraph, UnitDiskGraph, Hypergraph
83-
84-
## Conventions
85-
86-
### File Naming
87-
- Reduction files: `src/rules/<source>_<target>.rs`
88-
- Model files: `src/models/<category>/<name>.rs`
89-
- Test naming: `test_<source>_to_<target>_closed_loop`
90-
91-
### Reduction Pattern (Recommended: Using Macro)
92-
```rust
93-
use problemreductions::reduction;
94-
95-
#[reduction(
96-
overhead = { ReductionOverhead::new(vec![...]) }
97-
)]
98-
impl ReduceTo<TargetProblem<Unweighted>> for SourceProblem<Unweighted> {
99-
type Result = ReductionSourceToTarget;
100-
fn reduce_to(&self) -> Self::Result { ... }
101-
}
102-
```
103-
104-
The `#[reduction]` macro automatically:
105-
- Extracts type names from the impl signature
106-
- Detects weighted vs unweighted from type parameters (`Unweighted` vs `i32`/`f64`)
107-
- Detects graph types from type parameters (e.g., `GridGraph`, `SimpleGraph`)
108-
- Generates the `inventory::submit!` call
109-
110-
Optional macro attributes:
111-
- `source_graph = "..."` - Override detected source graph type
112-
- `target_graph = "..."` - Override detected target graph type
113-
- `source_weighted = true/false` - Override weighted detection
114-
- `target_weighted = true/false` - Override weighted detection
115-
- `overhead = { ... }` - Specify reduction overhead
116-
117-
### Manual Registration (Alternative)
118-
```rust
119-
inventory::submit! {
120-
ReductionEntry {
121-
source_name: "SourceProblem",
122-
target_name: "TargetProblem",
123-
source_variant: &[("graph", "SimpleGraph"), ("weight", "Unweighted")],
124-
target_variant: &[("graph", "SimpleGraph"), ("weight", "Unweighted")],
125-
overhead_fn: || ReductionOverhead::new(...),
126-
}
127-
}
128-
```
129-
130-
### Weight Types
131-
- `Unweighted` - Marker type for unweighted problems (all weights = 1)
132-
- `i32`, `f64`, etc. - Concrete weight types for weighted problems
63+
- Weight types: `Unweighted` (marker), `i32`, `f64`
13364

13465
### Problem Variant IDs
13566
Reduction graph nodes use variant IDs: `ProblemName[/GraphType][/Weighted]`
@@ -138,55 +69,18 @@ Reduction graph nodes use variant IDs: `ProblemName[/GraphType][/Weighted]`
13869
- Weighted variant: `IndependentSet/Weighted`
13970
- Both: `IndependentSet/GridGraph/Weighted`
14071

141-
## Anti-patterns
142-
- Don't create reductions without closed-loop tests
143-
- Don't forget `inventory::submit!` registration (graph won't update)
144-
- Don't hardcode weights - use generic `W` parameter
145-
- Don't skip `make clippy` before PR
146-
147-
## Documentation Requirements
148-
149-
The technical paper (`docs/paper/reductions.typ`) must include:
150-
151-
1. **Table of Contents** - Auto-generated outline of all sections
152-
2. **Problem Data Structures** - For each problem definition, include the Rust struct with fields in a code block
153-
3. **Reduction Examples** - For each reduction theorem, include a minimal working example showing:
154-
- Creating the source problem
155-
- Reducing to target problem
156-
- Solving and extracting solution back
157-
- Based on closed-loop tests from `tests/reduction_tests.rs`
158-
159-
### Documentation Pattern
160-
```typst
161-
#definition("Problem Name")[
162-
Mathematical definition...
163-
]
164-
165-
// Rust data structure
166-
```rust
167-
pub struct ProblemName<W = i32> {
168-
field1: Type1,
169-
field2: Type2,
170-
}
171-
`` `
172-
173-
#theorem[
174-
*(Source → Target)* Reduction description...
175-
]
72+
## Conventions
17673

177-
// Minimal working example
178-
```rust
179-
let source = SourceProblem::new(...);
180-
let reduction = ReduceTo::<TargetProblem>::reduce_to(&source);
181-
let target = reduction.target_problem();
182-
// ... solve and extract
183-
`` `
184-
```
74+
### File Naming
75+
- Reduction files: `src/rules/<source>_<target>.rs`
76+
- Model files: `src/models/<category>/<name>.rs`
77+
- Test naming: `test_<source>_to_<target>_closed_loop`
18578

18679
## Contributing
18780
See `.claude/rules/` for detailed guides:
18881
- `adding-reductions.md` - How to add reduction rules
18982
- `adding-models.md` - How to add problem types
19083
- `testing.md` - Testing requirements and patterns
84+
- `documentation.md` - Paper documentation patterns
19185

19286
Also see GitHub Issue #3 for coding rules.

.claude/rules/adding-reductions.md

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,33 @@ paths:
99
Create `src/rules/<source>_<target>.rs`:
1010

1111
```rust
12-
// Register reduction for automatic discovery (adds edge + metadata)
13-
inventory::submit! {
14-
ReductionEntry {
15-
source_name: "SourceProblem",
16-
target_name: "TargetProblem",
17-
source_graph: "SourceProblem",
18-
target_graph: "TargetProblem",
19-
overhead_fn: || ReductionOverhead::new(vec![
20-
("num_vars", Polynomial { terms: vec![...] }),
21-
("num_constraints", Polynomial { terms: vec![...] }),
22-
]),
23-
}
24-
}
12+
use problemreductions::reduction;
2513

26-
impl ReduceTo<TargetProblem> for SourceProblem {
14+
#[reduction(
15+
overhead = { ReductionOverhead::new(vec![...]) }
16+
)]
17+
impl ReduceTo<TargetProblem<Unweighted>> for SourceProblem<Unweighted> {
2718
type Result = ReductionSourceToTarget;
2819
fn reduce_to(&self) -> Self::Result { ... }
2920
}
3021
```
3122

23+
The `#[reduction]` macro auto-generates the `inventory::submit!` call. Optional attributes: `source_graph`, `target_graph`, `source_weighted`, `target_weighted`.
24+
3225
Register module in `src/rules/mod.rs`:
3326
```rust
3427
mod source_target;
3528
pub use source_target::ReductionSourceToTarget;
3629
```
3730

3831
## 2. Closed-Loop Test (Required)
39-
```rust
40-
#[test]
41-
fn test_closed_loop() {
42-
// 1. Create small instance A
43-
let problem = SourceProblem::new(...);
44-
45-
// 2. Reduce A to B
46-
let reduction = ReduceTo::<TargetProblem>::reduce_to(&problem);
47-
let target = reduction.target_problem();
4832

49-
// 3. Solve B
50-
let solver = TargetSolver::new();
51-
let target_solution = solver.solve(target).unwrap();
52-
53-
// 4. Extract solution of A
54-
let extracted = reduction.extract_solution(&target_solution);
55-
56-
// 5. Verify solution
57-
assert!(problem.is_valid_solution(&extracted));
58-
}
59-
```
33+
See `rules/testing.md` for the full pattern. Test name: `test_<source>_to_<target>_closed_loop`.
6034

6135
## 3. Documentation
62-
Update `docs/paper/reductions.typ`:
36+
Update `docs/paper/reductions.typ` (see `rules/documentation.md` for the pattern):
6337
- Add theorem + proof sketch
64-
- Add code example (note feature requirements if any)
38+
- Add code example
6539
- Add to summary table with overhead and citation
6640

6741
Citations must be verifiable. Use `[Folklore]` or `` for trivial reductions.

.claude/rules/documentation.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
paths:
3+
- "docs/paper/**/*.typ"
4+
---
5+
6+
# Documentation Requirements
7+
8+
The technical paper (`docs/paper/reductions.typ`) must include:
9+
10+
1. **Table of Contents** - Auto-generated outline of all sections
11+
2. **Problem Data Structures** - Rust struct with fields in a code block
12+
3. **Reduction Examples** - Minimal working example showing reduce → solve → extract
13+
14+
## Pattern
15+
16+
```typst
17+
#definition("Problem Name")[
18+
Mathematical definition...
19+
]
20+
21+
// Rust data structure
22+
```rust
23+
pub struct ProblemName<W = i32> {
24+
field1: Type1,
25+
field2: Type2,
26+
}
27+
`` `
28+
29+
#theorem[
30+
*(Source → Target)* Reduction description...
31+
]
32+
33+
// Minimal working example from closed-loop tests
34+
```rust
35+
let source = SourceProblem::new(...);
36+
let reduction = ReduceTo::<TargetProblem>::reduce_to(&source);
37+
let target = reduction.target_problem();
38+
// ... solve and extract
39+
`` `
40+
```

.claude/skills/issue-to-pr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Do NOT skip brainstorming. Do NOT write a plan without user discussion.
6262

6363
### 4. Write Plan
6464

65-
After brainstorming concludes, write plan to `docs/plans/issue-<number>-<slug>.md`:
65+
After brainstorming concludes, write plan to `issue-<number>-<slug>.md` in the repo root:
6666

6767
```markdown
6868
# <Title from brainstorming>
@@ -91,7 +91,7 @@ Issue: #<number>
9191
git checkout -b issue-<number>-<slug>
9292

9393
# Stage only the plan file
94-
git add docs/plans/issue-<number>-<slug>.md
94+
git add issue-<number>-<slug>.md
9595

9696
# Commit
9797
git commit -m "Add plan for #<number>: <title>"

.github/workflows/ci.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ jobs:
4949
steps:
5050
- uses: actions/checkout@v4
5151
- uses: dtolnay/rust-toolchain@stable
52+
with:
53+
components: llvm-tools-preview
5254
- uses: Swatinem/rust-cache@v2
53-
- name: Install tarpaulin
54-
run: cargo install cargo-tarpaulin
55+
- name: Install cargo-llvm-cov
56+
uses: taiki-e/install-action@cargo-llvm-cov
5557
- name: Generate coverage
56-
run: cargo tarpaulin --skip-clean --ignore-tests --out xml
57-
- name: Upload to Codecov
58+
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
59+
- name: Upload to codecov.io
5860
uses: codecov/codecov-action@v4
5961
with:
60-
files: cobertura.xml
61-
fail_ci_if_error: false
62+
files: lcov.info
63+
fail_ci_if_error: false # Don't fail CI if upload fails
64+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/coverage.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Rust
22
/target/
3+
Cargo.lock
34
**/*.rs.bk
45
*.pdb
56

7+
# Developer-specific Claude Code settings
8+
.claude/settings.local.json
9+
610
# IDE
711
.idea/
812
.vscode/

0 commit comments

Comments
 (0)