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
@@ -116,13 +125,25 @@ Right after the user picks model or rule, **study at least one existing case** i
116
125
117
126
### For Rules
118
127
119
-
1. Ask the user a brief orienting question (free text):
120
-
> "Which two problems are you thinking of connecting? Even a rough idea is fine."
128
+
1.**Run topology analysis first** to identify the most impactful missing reductions, then present the top candidates as recommendations. Only ask the user an open-ended "which two problems?" question if they don't have a specific pair in mind — otherwise, use the topology data to populate `AskUserQuestion` options in Step 3.1 directly.
129
+
130
+
Run these commands silently before asking any questions:
131
+
```bash
132
+
# Core data (fast — uses pre-built pred binary)
133
+
pred list --json
134
+
gh issue list --label rule --state open --limit 500 --json number,title
121
135
122
-
2. Based on the answer, study one existing reduction between similar problems. Use `pred neighbors <source_or_target> --json` to find existing reductions, then pick the most relevant one and examine it:
136
+
# Topology analysis (slower — compiles example binaries, but gives orphan/NP-hardness data)
137
+
cargo run --example detect_isolated_problems 2>/dev/null
138
+
cargo run --example detect_unreachable_from_3sat 2>/dev/null
139
+
```
140
+
Run the first two commands in parallel. The example binaries take longer but provide essential orphan/NP-hardness gap data for ranking recommendations.
141
+
142
+
2. Based on the topology results, study one existing reduction between similar problems. Use `pred to` and `pred from` to find existing reductions, then pick the most relevant one and examine it:
123
143
124
144
```bash
125
-
pred neighbors <problem> --json
145
+
pred to <problem> --json # problems that reduce TO this one (incoming)
146
+
pred from <problem> --json # problems this reduces FROM (outgoing)
126
147
```
127
148
128
149
Also find and read one closed `[Rule]` issue in a similar domain:
@@ -145,10 +166,12 @@ Right after the user picks model or rule, **study at least one existing case** i
145
166
146
167
## Step 2: Explore Context
147
168
148
-
Before asking questions, check what already exists. Try`pred`; if not available, build it first with `make cli`.
169
+
Before asking questions, check what already exists. Use`pred` if it's already installed; only build if the command is missing.
149
170
150
171
```bash
151
-
pred list --json 2>/dev/null || (make cli && pred list --json)
172
+
# Only build if pred is not already installed — make cli takes >1 minute
173
+
command -v pred >/dev/null 2>&1|| make cli
174
+
pred list --json
152
175
```
153
176
154
177
Also **search for existing GitHub issues** to avoid duplicates and surface related work:
@@ -370,62 +393,92 @@ After model brainstorming is complete, proceed to **Step 3b: Topology Analysis**
370
393
371
394
### For Rules (standalone)
372
395
373
-
Work through these topics in order, using `AskUserQuestion` for each step. (The orienting "Which two problems?" question was already asked in Step 1b, and conventions were studied.)
396
+
Topology analysis was already run in Step 1b. Conventions were studied.
374
397
375
-
1.**Which problems?** — First run topology analysis (orphans, NP-hardness gaps, `pred list --json`) to identify the most needed rules. Incorporate what the user mentioned in Step 1b, then present suggestions via `AskUserQuestion`:
398
+
#### Step 3.1: Recommend rules
376
399
377
-
```
378
-
AskUserQuestion:
379
-
question: "Which reduction would you like to propose?"
380
-
header: "Reduction"
381
-
options:
382
-
- label: "<Source> → <Target> (Recommended)"
383
-
description: "<why this is the most valuable — e.g., connects orphan, fills NP-hardness gap>"
384
-
- label: "<Source> → <Target>"
385
-
description: "<why valuable>"
386
-
- label: "<Source> → <Target>"
387
-
description: "<why valuable>"
388
-
- label: "I have a different pair"
389
-
description: "I'll describe the source and target problems"
390
-
```
400
+
Use the topology data from Step 1b to present **data-driven recommendations** via `AskUserQuestion`. The options should be populated from the analysis — do not ask the user to name problems before you have analyzed the graph.
391
401
392
-
Populate the suggestions based on topology analysis:
description: "<why valuable — note existing issues if any>"
411
+
- label: "<Source> → <Target>"
412
+
description: "<why valuable — note existing issues if any>"
413
+
- label: "I have a different pair"
414
+
description: "I'll describe the source and target problems"
415
+
```
396
416
397
-
After selection, verify both problems exist (or one is being proposed alongside).
417
+
**Selection criteria** (in priority order) — only suggest rules where **both source and target already exist** in the codebase:
418
+
-**Priority 1:** Rules that connect orphan problems to the main component (check `detect_isolated_problems` output)
419
+
-**Priority 2:** Rules that fill NP-hardness proof gaps (check `detect_unreachable_from_3sat` output)
420
+
-**Priority 3:** Rules to large clusters (QUBO, ILP, SAT families)
421
+
-**Filter:** Exclude pairs that already have a reduction registered **AND** pairs that already have an open GitHub issue filed (even if not yet implemented). Do not recommend duplicates — if an issue exists, it should be implemented via `/issue-to-pr`, not re-proposed.
398
422
399
-
2.**Why useful?** — Use `AskUserQuestion`:
400
-
```
401
-
AskUserQuestion:
402
-
question: "What makes this reduction valuable?"
403
-
header: "Motivation"
404
-
options:
405
-
- label: "Connects an isolated problem"
406
-
description: "Links an orphan problem to the main graph"
407
-
- label: "Enables a new solver"
408
-
description: "Allows solving via the target problem's solvers (e.g., ILP, QUBO)"
409
-
- label: "Proves NP-hardness"
410
-
description: "Establishes hardness via a chain from 3-SAT"
411
-
- label: "Shorter reduction path"
412
-
description: "Provides a more efficient path than what currently exists"
413
-
```
414
-
Also check if a path already exists: `pred path <source> <target> --json`
423
+
After selection, verify both problems exist (or one is being proposed alongside).
424
+
425
+
#### Step 3.2: Study source and target models
426
+
427
+
**Mandatory before any brainstorming.** Inspect both models in the codebase:
428
+
429
+
```bash
430
+
pred show <source> --json
431
+
pred show <target> --json
432
+
```
433
+
434
+
Note internally (do not dump to the user):
435
+
- Field names, types, and size getters for both problems
436
+
- Whether source/target are optimization or satisfaction problems
437
+
- Type mismatches (e.g., `BigUint` vs `i64`) that the reduction must handle
438
+
- Existing reductions to/from both problems (use `pred to` and `pred from`)
439
+
440
+
Also check for existing GitHub issues for this specific pair:
441
+
```bash
442
+
gh issue list --label rule --state open --json number,title | jq '.[] | select(.title | test("<source>.*<target>"; "i"))'
443
+
```
415
444
416
-
3.**Algorithm** — Ask as a free-text question (no multiple choice here):
445
+
This information is essential for writing correct overhead tables and identifying implementation concerns.
446
+
447
+
#### Step 3.3: Well-known reduction fast path
448
+
449
+
After studying the models, determine whether this is a **well-known textbook reduction**:
450
+
- Use WebSearch to check standard references (Garey & Johnson, Karp's 21, CLRS, Sipser, Arora & Barak)
451
+
- Check if an existing GitHub issue already describes this reduction
452
+
453
+
**If the reduction is well-known** (found in at least one textbook or survey):
454
+
-**Do NOT ask brainstorming questions** (motivation, algorithm, correctness, overhead, example, reference) — the answers are in the literature
455
+
- Auto-fill every section by researching the literature and using the model data from Step 3.2
456
+
- Jump directly to **Step 4: Present Draft Issue(s)**
457
+
- The draft presentation is the user's review point — they can revise any section there
458
+
459
+
**If the reduction is NOT well-known** (novel or obscure):
460
+
- Proceed to **Step 3.4: Guided brainstorming** below
461
+
462
+
> **Rationale:** Domain experts proposing a textbook reduction should not be quizzed on facts they already know. The skill's value is producing a well-formatted, correct issue — not asking obvious questions. For novel reductions, guided brainstorming helps the user think through the design.
Only reach this step if the reduction is novel or obscure. Work through these topics in order. **Do not use `AskUserQuestion` when the answer is determinable from topology analysis, model inspection, or literature search** — just auto-fill and note what you filled. Only ask when genuine user input is needed.
467
+
468
+
1.**Why useful?** — If the topology analysis already shows this connects an orphan, fills an NP-hardness gap, or provides a shorter path, **state the motivation directly** — do not ask. Only use `AskUserQuestion` if the motivation is genuinely ambiguous.
469
+
470
+
2.**Algorithm** — Ask as a free-text question (no multiple choice here):
417
471
> "How does the reduction work? Given a source instance, how do you construct the target instance? Please describe step by step."
418
472
- Must define all symbols before using them
419
473
- Must be detailed enough that someone could implement it
420
474
- If the user is unsure, use WebSearch to find known reductions in the literature
421
475
422
-
4.**Correctness** — Ask as free text:
476
+
3.**Correctness** — Ask as free text:
423
477
> "Why does this work? Why does an optimal solution to the target correspond to an optimal solution of the source?"
424
478
425
-
5.**Size overhead** — Ask as free text:
426
-
> "How large is the target instance relative to the source? E.g., if the source has n vertices and m edges, how many variables/constraints does the target have?"
479
+
4.**Size overhead** — Auto-fill from the algorithm description using the target's size fields from `pred show <target> --json`. Ask the user to confirm only if the overhead is unclear from the algorithm.
427
480
428
-
6.**Example** — Generate 3 candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`:
481
+
5.**Example** — Generate 3 candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`:
429
482
430
483
```
431
484
AskUserQuestion:
@@ -444,16 +497,14 @@ Work through these topics in order, using `AskUserQuestion` for each step. (The
444
497
- Must be non-trivial but hand-verifiable
445
498
- Must exercise the core structure of the reduction
446
499
447
-
7.**Reference** — Use `AskUserQuestion`:
500
+
6.**Reference** — Use WebSearch to find references first. Only use `AskUserQuestion` if no reference is found:
448
501
```
449
502
AskUserQuestion:
450
503
question: "Is there a paper or textbook that describes this reduction?"
451
504
header: "Reference"
452
505
options:
453
506
- label: "Yes, I have a reference"
454
507
description: "I'll provide the citation"
455
-
- label: "No, please help find one"
456
-
description: "Search the literature for a known reduction"
457
508
- label: "This is a novel reduction"
458
509
description: "I designed this myself — no existing reference"
459
510
```
@@ -474,7 +525,7 @@ cargo run --example detect_unreachable_from_3sat 2>/dev/null
474
525
# List existing problems and reductions
475
526
pred list --json
476
527
477
-
# Check if paths exist between the new problem's likely neighbors
528
+
# Check if paths exist between the new problem's likely reduction targets
478
529
pred path <similar_problem_A><similar_problem_B> --json
479
530
```
480
531
@@ -643,7 +694,9 @@ Print all issue URLs when done.
643
694
644
695
## Key Principles
645
696
646
-
-**Use `AskUserQuestion` for structured choices** — whenever the user needs to pick from options (type detection, problem selection, motivation, variable type, data structure, reference type, approval), use the `AskUserQuestion` tool with well-labeled options. Use free text only for open-ended questions (algorithm description, formal definitions, examples, complexity expressions).
697
+
-**Use `AskUserQuestion` only when genuine user input is needed** — use it for choices where the answer is NOT determinable from context (type detection, problem selection, example selection, approval). Do NOT use it when the answer is already clear from topology analysis, model inspection, or literature (e.g., don't ask "why is this useful?" when the topology analysis already shows it connects an orphan).
698
+
-**Study models before brainstorming** — always run `pred show <source> --json` and `pred show <target> --json` before asking questions. This reveals field types, size getters, and schema details that are essential for correct overhead tables.
699
+
-**Fast-path well-known reductions** — if the reduction appears in standard textbooks, skip all brainstorming questions and auto-fill the draft from literature + model data. Present the draft directly for review.
647
700
-**One question at a time** — don't overwhelm; each `AskUserQuestion` call has one focused question
648
701
-**Mathematical language only** — never mention Rust types, traits, macros, or code patterns to the user
649
702
-**Help find references** — use WebSearch to help locate papers, verify claims
@@ -655,8 +708,11 @@ Print all issue URLs when done.
655
708
656
709
## Common Mistakes
657
710
711
+
-**Don't ask questions with obvious answers.** If the topology analysis shows the rule connects an orphan, don't ask "What makes this reduction valuable?" — state it. Only use `AskUserQuestion` when the answer requires genuine user input.
712
+
-**Don't skip model inspection.** Always run `pred show <source> --json` and `pred show <target> --json` before brainstorming. Missing this leads to wrong overhead tables and missed type mismatches (e.g., `BigUint` vs `i64`).
713
+
-**Don't quiz users on textbook reductions.** If SubsetSum → Knapsack is in Garey & Johnson, don't ask the user to explain the algorithm step by step — look it up and draft the issue.
714
+
-**Don't rebuild `pred` unnecessarily.** Use `command -v pred` to check if it's installed before running `make cli` (which takes >1 minute).
658
715
-**Don't ask all questions at once.** One `AskUserQuestion` call per message.
659
-
-**Don't use plain text for structured choices.** If the user needs to pick from options, use `AskUserQuestion` — not a bulleted list in plain text.
660
716
-**Don't use programming jargon.** Say "list of weights" not "Vec<W>". Say "graph" not "SimpleGraph". Say "integer" not "i32".
661
717
-**Don't skip the reduction crossref.** An orphan model will be rejected.
662
718
-**Don't file without user approval.** Always show the draft first.
0 commit comments