Generate research questions from structural gaps to guide knowledge exploration. Use when user asks what to explore next, needs research direction, or requires gap-bridging guidance.
Purpose: Auto-generate research questions from structural gaps to guide knowledge exploration
Backend: backend/services/question-generator.cjs (264 lines)
Status: ✅ Operational (implemented Phase 2)
Generates targeted research questions from detected gaps in knowledge graphs, helping users explore connections and fill structural holes.
Key Capabilities:
Use question generation when:
Structural Questions (disconnected clusters):
Topical Questions (topic mismatch):
Semantic Questions (meaning gap):
Logical Questions (missing causal links):
Cluster-Level:
{clusterA} / {clusterB} - Cluster IDs (e.g., 0, 1, 2){topicA} / {topicB} - Cluster topics (if labeled)Concept-Level:
{conceptsA} / {conceptsB} - Top 3 concepts from each cluster (comma-separated){keyA} / {keyB} - Highest centrality concept from each clusterExample Substitution:
Template: "What logical steps connect {keyA} to {keyB}?"
Variables: { keyA: "revenue", keyB: "management" }
Output: "What logical steps connect revenue to management?"
{
question: "What logical steps connect revenue to management?",
gap: {
from: 0, // Cluster A ID
to: 3, // Cluster B ID
severity: "major",
score: 0.805
},
type: "logical",
bridgeConcepts: ["relationship", "connection"]
}
Heuristic Rules:
Generic Bridge Concepts:
Example:
Cluster A: ["revenue", "projections", "cost"]
Cluster B: ["management", "strategy", "decisions"]
Suggested bridges: ["relationship", "connection"]
{
maxQuestionsPerGap: 3, // Questions generated per gap
maxTotalQuestions: 15, // Total questions across all gaps
minGapSeverity: 'minor' // Only generate for minor+ gaps
}
Defaults:
Priority Order:
Deduplication:
[
"What logical steps connect revenue to management?",
"How do cluster 0 and cluster 3 relate?",
"What causes the relationship between cluster 0 and cluster 2?"
]
[
{
question: "What logical steps connect revenue to management?",
gap: "0 → 3",
severity: "major",
score: "0.805",
type: "logical",
suggestedBridges: "relationship, connection"
}
]
1. **What logical steps connect revenue to management?**
- Gap: 0 → 3 (major)
- Suggested bridges: relationship, connection
2. **How do cluster 0 and cluster 2 relate?**
- Gap: 0 → 2 (minor)
- Suggested bridges: relationship, connection
Called by:
backend/services/agent-graph-service.cjs:145-151 (automatic on every analysis)Depends on:
Outputs:
No regression: Analysis time 16-76ms maintained from Phase 1
# Test question generation
node -e "
const { analyzeForAgent } = require('./backend/services/agent-graph-service.cjs');
(async () => {
const result = await analyzeForAgent('finance', 'revenue projections cost structure burn rate management metrics');
console.log('Questions generated:', result.researchQuestions.length);
console.log('');
result.researchQuestions.forEach((q, i) => {
console.log(\`\${i+1}. \${q.question}\`);
console.log(\` Gap: \${q.gap.from} → \${q.gap.to} (\${q.gap.severity})\`);
});
})();
"
# Expected output:
# Questions generated: 9
#
# 1. What logical steps connect revenue to management?
# Gap: 0 → 3 (major)
# 2. What causes the relationship between cluster 0 and cluster 3?
# Gap: 0 → 3 (major)
# ...
Provided fields:
total - Total questions generatedbyType - Breakdown by structural/topical/semantic/logicalbySeverity - Breakdown by critical/major/minortopQuestions - Top 5 most important questionsExample:
{
total: 9,
byType: { structural: 0, topical: 0, semantic: 0, logical: 9 },
bySeverity: { critical: 0, major: 3, minor: 6 },
topQuestions: [
"What logical steps connect revenue to management?",
"How do cluster 0 and cluster 3 relate?",
...
]
}
@finance (Financial Analysis):
9 questions generated from 3 gaps:
1. What logical steps connect revenue to management?
Gap: 0 → 3 (major, score=0.805)
Bridges: relationship, connection
2. What causes the relationship between cluster 0 and cluster 3?
Gap: 0 → 3 (major)
3. What are the implications of connecting cluster 0 with cluster 3?
Gap: 0 → 3 (major)
4. What logical steps connect revenue to forecasting?
Gap: 0 → 2 (minor, score=0.786)
... (9 total)
@marketing (Campaign Strategy):
3 questions generated from 1 gap:
1. What logical steps connect product to conversion?
Gap: 0 → 1 (major, score=0.702)
Bridges: relationship, connection
2. What causes the relationship between cluster 0 and cluster 1?
Gap: 0 → 1 (major)
3. What are the implications of connecting cluster 0 with cluster 1?
Gap: 0 → 1 (major)
@seo (Search Optimization):
3 questions generated from 1 gap:
1. What semantic relationship exists between keywords and performance?
Gap: 1 → 2 (minor, score=0.654)
Bridges: relationship, connection
2. How are keyword, research conceptually similar to performance, rankings?
Gap: 1 → 2 (minor)
3. What shared meaning connects cluster 1 and cluster 2?
Gap: 1 → 2 (minor)
Concept Extraction:
Template Filling:
\{variableName\} → actual valueDeduplication Algorithm:
Current constraints:
Future enhancements (not implemented):
Implementation: Phase 2 (2025-11-06) Test Status: ✅ Verified operational across @marketing, @seo, @finance Documentation: workspace/docs/Obsidian-v2/daily/2025-11-06-PHASE2-COMPLETE.md