Skip to content

Commit 13249b3

Browse files
GiggleLiuclaude
andauthored
feat: explicit variant declarations with complexity metadata (#102)
* fix: show full variant values in `pred show` variants list The variants list now shows all values (e.g., MIS/SimpleGraph/i32) instead of hiding default values. This makes it clear what graph and weight types each variant uses. The diff-from-default slash notation is still used for reduction edges to keep them concise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: support slash variant notation in pred create (e.g., MIS/KingsSubgraph) - Use parse_problem_spec + resolve_variant instead of resolve_alias so `pred create MIS/KingsSubgraph --graph ...` works - Resolved variant from reduction graph is used in output JSON instead of hardcoded variant maps - Simplify KColoring and KSatisfiability branches by removing redundant local variant variables Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * cli improvement * feat: add DeclaredVariant marker trait Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add VariantEntry inventory struct Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add declare_variants! macro Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add declare_variants! to graph model files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add declare_variants! to remaining model files Adds variant declarations for optimization (QUBO, SpinGlass, ILP), satisfiability (Satisfiability, KSatisfiability), set (MaximumSetPacking, MinimumSetCovering), and specialized (CircuitSAT, Factoring) models. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: #[reduction] now checks DeclaredVariant at compile time Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: ReductionGraph builds nodes from VariantEntry with complexity Phase 1 now builds variant nodes from VariantEntry inventory (with complexity metadata), then Phase 2 creates edges from ReductionEntry. Adds variant_complexity() getter for querying a variant's time complexity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: include complexity in graph JSON export Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: display per-variant complexity in pred show Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: sort variants_for() deterministically (default variant first) * chore: fix formatting, clippy, and doctest issues - Remove unused `mut` from ensure_node closure - Sort variants_for() deterministically (default variant first) - Change declare_variants! doctest from `ignore` to `text` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: cover VariantEntry Debug and variant_complexity None branch Adds test coverage for the two uncovered patch areas: - VariantEntry Debug formatting - variant_complexity returning None for unknown problems Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: validate K-param consistency and extract shared CLI/MCP utils - Add validate_k_param() to detect contradictions between variant suffix (e.g., /K2) and --k flag (e.g., --k 3) for KColoring/KSatisfiability - Extract shared helpers (ser, variant_map, parse_positions, LCG, random graph generation) into util.rs to eliminate CLI/MCP duplication - Apply consistent K-param validation in both CLI create and MCP create_problem paths (including random generation) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add design for review-implementation as parallel subagents Split review-implementation into two parallel subagents (structural + quality) dispatched with fresh context. Integrates with executing-plans after each batch and standalone /review-implementation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add structural and quality reviewer prompt templates Self-contained prompt templates for review subagents: - structural-reviewer-prompt.md: model/rule checklists + semantic review - quality-reviewer-prompt.md: DRY, KISS, HC/LC, HCI, test quality Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: rewrite review-implementation as subagent orchestrator SKILL.md now dispatches two parallel subagents (structural + quality) with fresh context instead of running checks inline. Detection uses git diff --diff-filter=A to find new model/rule files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: update review-implementation description in CLAUDE.md Reflects new subagent-based dispatch and executing-plans integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve PR review comments (dedup wrappers, MCP overhead, doc fix) - Remove thin wrapper functions in create.rs, use util:: directly - Add overhead info to MCP show_problem edge JSON (matching CLI output) - Fix UnitDiskGraph variant type in design doc (f64 → i32) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: remove working plan files from branch These were implementation plans consumed during development and are no longer needed in the tree. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add copilot-review step after PR creation Instructs the agent to run `make copilot-review` after creating a PR to get GitHub Copilot code review feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * copilot review * feat: add fix-pr skill for resolving PR feedback New skill that handles: - Fetching and triaging PR review comments (user + Copilot) - Checking CI status via gh api - Fixing codecov coverage gaps using gh api (not local cargo-llvm-cov) - Structured workflow: gather -> triage -> fix -> verify -> report Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix MIS reduction * fix MIS to UDG issue * fix One default --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8c1bbdb commit 13249b3

57 files changed

Lines changed: 2415 additions & 650 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/CLAUDE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Rust library for NP-hard problem reductions. Implements computational problems w
77
- [issue-to-pr](skills/issue-to-pr/SKILL.md) -- Convert a GitHub issue into a PR with an implementation plan. Validates the issue against the appropriate checklist, then dispatches to `add-model` or `add-rule`.
88
- [add-model](skills/add-model/SKILL.md) -- Add a new problem model. Can be used standalone (brainstorms with user) or called from `issue-to-pr`.
99
- [add-rule](skills/add-rule/SKILL.md) -- Add a new reduction rule. Can be used standalone (brainstorms with user) or called from `issue-to-pr`.
10-
- [review-implementation](skills/review-implementation/SKILL.md) -- Review a model or rule implementation for completeness. Auto-detects type from changed files. Called automatically at the end of `add-model`/`add-rule`, or standalone via `/review-implementation`.
10+
- [review-implementation](skills/review-implementation/SKILL.md) -- Review implementation completeness by dispatching parallel subagents (structural + quality) with fresh context. Auto-detects new models/rules from git diff. Called automatically at the end of `add-model`/`add-rule`, after each `executing-plans` batch, or standalone via `/review-implementation`.
11+
- [fix-pr](skills/fix-pr/SKILL.md) -- Resolve PR review comments (user + Copilot), fix CI failures, and address codecov coverage gaps. Uses `gh api` for codecov (not local `cargo-llvm-cov`).
1112
- [release](skills/release/SKILL.md) -- Create a new crate release. Determines version bump from diff, verifies tests/clippy, then runs `make release`.
1213

1314
## Commands
@@ -35,6 +36,7 @@ make cli # Build the pred CLI tool (release mode)
3536
make cli-demo # Run closed-loop CLI demo (exercises all commands)
3637
make mcp-test # Run MCP server tests (unit + integration)
3738
make run-plan # Execute a plan with Claude autorun
39+
make copilot-review # Request Copilot code review on current PR
3840
make release V=x.y.z # Tag and push a new release (CI publishes to crates.io)
3941
```
4042

@@ -119,8 +121,9 @@ Problem types use explicit optimization prefixes:
119121
### Problem Variant IDs
120122
Reduction graph nodes use variant key-value pairs from `Problem::variant()`:
121123
- Base: `MaximumIndependentSet` (empty variant = defaults)
122-
- Graph variant: `MaximumIndependentSet {graph: "GridGraph", weight: "i32"}`
124+
- Graph variant: `MaximumIndependentSet {graph: "KingsSubgraph", weight: "One"}`
123125
- Weight variant: `MaximumIndependentSet {graph: "SimpleGraph", weight: "f64"}`
126+
- Default variant ranking: `SimpleGraph`, `One`, `KN` are considered default values; variants with the most default values sort first
124127
- Nodes come exclusively from `#[reduction]` registrations; natural edges between same-name variants are inferred from the graph/weight subtype partial order
125128

126129
## Conventions

.claude/skills/fix-pr/SKILL.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
name: fix-pr
3+
description: Use when a PR has review comments to address, CI failures to fix, or codecov coverage gaps to resolve
4+
---
5+
6+
# Fix PR
7+
8+
Resolve PR review comments, fix CI failures, and address codecov coverage gaps for the current branch's PR.
9+
10+
## Step 1: Gather PR State
11+
12+
```bash
13+
# Get PR number
14+
PR=$(gh pr view --json number --jq .number)
15+
16+
# Get PR head SHA (on remote)
17+
HEAD_SHA=$(gh api repos/{owner}/{repo}/pulls/$PR --jq '.head.sha')
18+
```
19+
20+
### 1a. Fetch Review Comments
21+
22+
Three sources of feedback to check:
23+
24+
```bash
25+
# Copilot and user inline review comments (on code lines)
26+
gh api repos/{owner}/{repo}/pulls/$PR/comments --jq '.[] | "[\(.user.login)] \(.path):\(.line // .original_line) — \(.body)"'
27+
28+
# Review-level comments (top-level review body)
29+
gh api repos/{owner}/{repo}/pulls/$PR/reviews --jq '.[] | select(.body != "") | "[\(.user.login)] \(.state): \(.body)"'
30+
31+
# Issue-level comments (general discussion)
32+
gh api repos/{owner}/{repo}/issues/$PR/comments --jq '.[] | select(.user.login | test("codecov|copilot") | not) | "[\(.user.login)] \(.body)"'
33+
```
34+
35+
### 1b. Check CI Status
36+
37+
```bash
38+
# All check runs on the PR head
39+
gh api repos/{owner}/{repo}/commits/$HEAD_SHA/check-runs \
40+
--jq '.check_runs[] | "\(.name): \(.conclusion // .status)"'
41+
```
42+
43+
### 1c. Check Codecov Report
44+
45+
```bash
46+
# Codecov bot comment with coverage diff
47+
gh api repos/{owner}/{repo}/issues/$PR/comments \
48+
--jq '.[] | select(.user.login == "codecov[bot]") | .body'
49+
```
50+
51+
## Step 2: Triage and Prioritize
52+
53+
Categorize all findings:
54+
55+
| Priority | Type | Action |
56+
|----------|------|--------|
57+
| 1 | CI failures (test/clippy/build) | Fix immediately -- blocks merge |
58+
| 2 | User review comments | Address each one -- respond on PR |
59+
| 3 | Copilot review comments | Evaluate validity, fix if correct |
60+
| 4 | Codecov coverage gaps | Add tests for uncovered lines |
61+
62+
## Step 3: Fix CI Failures
63+
64+
For each failing check:
65+
66+
1. **Clippy**: Run `make clippy` locally, fix warnings
67+
2. **Test**: Run `make test` locally, fix failures
68+
3. **Build**: Run `make build` locally, fix errors
69+
4. **Coverage**: See Step 5 (codecov-specific flow)
70+
71+
## Step 4: Address Review Comments
72+
73+
For each review comment:
74+
75+
1. Read the comment and the code it references
76+
2. Evaluate if the suggestion is correct
77+
3. If valid: make the fix, commit
78+
4. If debatable: fix it anyway unless technically wrong
79+
5. If wrong: prepare a response explaining why
80+
81+
**Do NOT respond on the PR** -- just fix and commit. The user will push and respond.
82+
83+
### Handling Copilot Suggestions
84+
85+
Copilot suggestions with `suggestion` blocks contain exact code. Evaluate each:
86+
- **Correct**: Apply the suggestion
87+
- **Partially correct**: Apply the spirit, adjust details
88+
- **Wrong**: Skip, note why in commit message
89+
90+
## Step 5: Fix Codecov Coverage Gaps
91+
92+
**IMPORTANT: Do NOT run `cargo-llvm-cov` locally.** Use the `gh api` to read the codecov report instead.
93+
94+
### 5a. Identify Uncovered Lines
95+
96+
From the codecov bot comment (fetched in Step 1c), extract:
97+
- Files with missing coverage
98+
- Patch coverage percentage
99+
- Specific uncovered lines (linked in the report)
100+
101+
For detailed line-by-line coverage, use the Codecov API:
102+
103+
```bash
104+
# Get file-level coverage for the PR
105+
gh api repos/{owner}/{repo}/pulls/$PR/comments \
106+
--jq '.[] | select(.user.login == "codecov[bot]") | .body' \
107+
| grep -oP 'filepath=\K[^&]+'
108+
```
109+
110+
Then read the source files and identify which new/changed lines lack test coverage.
111+
112+
### 5b. Add Tests for Uncovered Lines
113+
114+
1. Read the uncovered file and identify the untested code paths
115+
2. Write tests targeting those specific paths (error branches, edge cases, etc.)
116+
3. Run `make test` to verify tests pass
117+
4. Commit the new tests
118+
119+
### 5c. Verify Coverage Improvement
120+
121+
After pushing, CI will re-run coverage. Check the updated codecov comment on the PR.
122+
123+
## Step 6: Commit and Report
124+
125+
After all fixes:
126+
127+
```bash
128+
# Verify everything passes locally
129+
make check # fmt + clippy + test
130+
```
131+
132+
Commit with a descriptive message referencing the PR:
133+
134+
```bash
135+
git commit -m "fix: address PR #$PR review comments
136+
137+
- [summary of fixes applied]
138+
"
139+
```
140+
141+
Report to user:
142+
- List of review comments addressed (with what was done)
143+
- CI fixes applied
144+
- Coverage gaps filled
145+
- Any comments left unresolved (with reasoning)
146+
147+
## Integration
148+
149+
### With review-implementation
150+
151+
Run `/review-implementation` first to catch issues before push. Then `/fix-pr` after push to address CI and reviewer feedback.
152+
153+
### With executing-plans / finishing-a-development-branch
154+
155+
After creating a PR and running `make copilot-review`, use `/fix-pr` to address the resulting feedback.

0 commit comments

Comments
 (0)