Skip to content

Commit 34b77c7

Browse files
GiggleLiuclaude
andcommitted
fix(skill+cli): correct pred direction in find-solver/find-problem, fix KColoring/KN serialization
find-solver Step 3 used `pred to` (incoming) when it should use `pred from` (outgoing) to find solver-ready targets. find-problem Step 2 had the mirror bug: `pred from` (outgoing) instead of `pred to` (incoming) for discovering problems that reduce to the user's model. Also fix KColoring/KN schema-driven creation: inject `num_colors` from --k into JSON so the value round-trips correctly. Without this, KN instances deserialized with num_colors=0, causing all solvers to return no solution. Found via agentic skill tests with simulated expert users. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 85f6d78 commit 34b77c7

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

.claude/skills/find-problem/SKILL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Step 4: Generate Solution Doc (docs/solutions/<name>.md)
3737

3838
Bash tool results are hidden from the user in the Claude Code UI. **After every `pred` command, you MUST copy-paste the full stdout/stderr into your response as text.** The pattern for every command is:
3939

40-
1. Announce the command and why: "Let me run `pred from MIS --hops 3` to discover all problems that can reduce to MIS:"
40+
1. Announce the command and why: "Let me run `pred to MIS --hops 3` to discover all problems that can reduce to MIS:"
4141
2. Run the command via the Bash tool
4242
3. Copy the COMPLETE output into your text response inside a fenced code block
4343
4. Then add your brief explanation
@@ -69,7 +69,7 @@ Never skip step 1 or 3.
6969

7070
**Actions:**
7171

72-
1. **Run `pred from <model> --hops 3`** to find all problems that can reduce to the user's model within 3 hops. Copy-paste the full output.
72+
1. **Run `pred to <model> --hops 3`** to find all problems that can reduce to the user's model within 3 hops (incoming direction). Copy-paste the full output.
7373

7474
2. **For each discovered problem**, run:
7575
- `pred path <source> <model>` — get the cheapest witness-capable reduction path
@@ -181,6 +181,6 @@ pred solve bundle.json --solver ilp --timeout 60
181181
- **Compact formatting.** Write explanations as plain paragraphs. Do not use blockquote `>` syntax for explanations. Keep tight: command announcement, code block output, 1-3 sentence explanation.
182182
- **Conversational tone.** Guided consultation, not a lecture.
183183
- **Live execution.** Every `pred` command runs for real. No fake output.
184-
- **Graceful fallbacks.** If `pred from` returns no results, suggest trying with more hops or a different model. If `pred path` fails for a specific source, skip it and note it in the table.
184+
- **Graceful fallbacks.** If `pred to` returns no results (no incoming reductions), suggest trying with more hops or a different model. If `pred path` fails for a specific source, skip it and note it in the table.
185185
- **Help with complexity notation.** If the user gives informal complexity, show `pred show <model>` size fields and help them write a formal expression.
186186
- **Cap results at 10.** If discovery returns many problems, show top 10 by effective complexity and offer to show more.

.claude/skills/find-solver/SKILL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Adapt the flow: if the user provides a formal problem name, validate it with `pr
3434
```
3535
Step 1: Clarify Problem (skip if user knows the formal name)
3636
Step 2: Match to Library Models (web search + pred list)
37-
Step 3: Explore Reduction Paths (auto-explore via pred to --hops 3)
37+
Step 3: Explore Reduction Paths (auto-explore via pred from --hops 3)
3838
Step 4: Recommend Solvers (web search + pred solve options)
3939
Step 5: Generate Solution Doc (docs/solutions/<name>.md)
4040
```
@@ -110,7 +110,7 @@ Use `AskUserQuestion` for each question. Format options as **(a)**/**(b)**/**(c)
110110

111111
**Actions:**
112112

113-
1. **Run `pred to <model> --hops 3`** to find all problems reachable within 3 hops. Copy-paste the full output.
113+
1. **Run `pred from <model> --hops 3`** to find all problems reachable via outgoing reductions within 3 hops. Copy-paste the full output.
114114

115115
2. **For each reachable problem**, gather info:
116116
- Run `pred path <model> <target>` to get the cheapest witness-capable reduction path and composed overhead
@@ -127,7 +127,7 @@ Use `AskUserQuestion` for each question. Format options as **(a)**/**(b)**/**(c)
127127

128128
4. **Ask the user** using `AskUserQuestion`: "Which reduction path would you like to use? Pick a number."
129129

130-
**If `--hops 3` returns more than 15 results:** present only the top 10 by overhead and mention the rest are available.
130+
**If `pred from --hops 3` returns more than 15 results:** present only the top 10 by overhead and mention the rest are available.
131131

132132
**Proceed to Step 4 with the chosen path.**
133133

problemreductions-cli/src/commands/create/schema_support.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ pub(super) fn create_schema_driven(
178178
json_map.insert(field.name.clone(), value);
179179
}
180180

181+
// KColoring/KN stores the number of colors at runtime in `num_colors`.
182+
// The schema only declares `graph`, so inject `num_colors` from --k for KN.
183+
if canonical == "KColoring"
184+
&& resolved_variant.get("k").map(|s| s.as_str()) == Some("KN")
185+
{
186+
if let Some(k) = args.k {
187+
json_map.insert("num_colors".to_string(), serde_json::json!(k));
188+
}
189+
}
190+
181191
// Decision<P> types serialize as {inner: {graph, weights, ...}, bound} but schema
182192
// fields are flat (graph, weights, bound). Restructure when the canonical name
183193
// indicates a Decision wrapper.

0 commit comments

Comments
 (0)