@memberjunction/db-auto-doc 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -26
- package/dist/commands/generate-queries.d.ts.map +1 -1
- package/dist/commands/generate-queries.js +3 -0
- package/dist/commands/generate-queries.js.map +1 -1
- package/dist/core/AnalysisOrchestrator.d.ts.map +1 -1
- package/dist/core/AnalysisOrchestrator.js +18 -2
- package/dist/core/AnalysisOrchestrator.js.map +1 -1
- package/dist/database/Database.d.ts.map +1 -1
- package/dist/database/Database.js +32 -20
- package/dist/database/Database.js.map +1 -1
- package/dist/drivers/SQLServerDriver.d.ts.map +1 -1
- package/dist/drivers/SQLServerDriver.js +20 -13
- package/dist/drivers/SQLServerDriver.js.map +1 -1
- package/dist/prompts/PromptEngine.d.ts.map +1 -1
- package/dist/prompts/PromptEngine.js +17 -17
- package/dist/prompts/PromptEngine.js.map +1 -1
- package/dist/prompts/PromptFileLoader.d.ts +1 -1
- package/dist/prompts/PromptFileLoader.d.ts.map +1 -1
- package/dist/prompts/PromptFileLoader.js +1 -1
- package/dist/prompts/PromptFileLoader.js.map +1 -1
- package/package.json +7 -6
- package/prompts/backpropagation.md +55 -0
- package/prompts/convergence-check.md +79 -0
- package/prompts/cross-schema-check.md +61 -0
- package/prompts/cross-schema-sanity-check.md +133 -0
- package/prompts/dependency-level-sanity-check.md +92 -0
- package/prompts/query-fix.md +141 -0
- package/prompts/query-planning.md +144 -0
- package/prompts/query-refinement.md +151 -0
- package/prompts/schema-level-sanity-check.md +114 -0
- package/prompts/schema-sanity-check.md +54 -0
- package/prompts/semantic-comparison.md +78 -0
- package/prompts/single-query-generation.md +155 -0
- package/prompts/table-analysis.md +139 -0
- package/dist/ai/simple-ai-client.d.ts +0 -70
- package/dist/ai/simple-ai-client.d.ts.map +0 -1
- package/dist/ai/simple-ai-client.js +0 -181
- package/dist/ai/simple-ai-client.js.map +0 -1
- package/dist/analyzers/analyzer.d.ts +0 -23
- package/dist/analyzers/analyzer.d.ts.map +0 -1
- package/dist/analyzers/analyzer.js +0 -127
- package/dist/analyzers/analyzer.js.map +0 -1
- package/dist/cli-old/cli.d.ts +0 -3
- package/dist/cli-old/cli.d.ts.map +0 -1
- package/dist/cli-old/cli.js +0 -388
- package/dist/cli-old/cli.js.map +0 -1
- package/dist/commands/review.d.ts +0 -11
- package/dist/commands/review.d.ts.map +0 -1
- package/dist/commands/review.js +0 -82
- package/dist/commands/review.js.map +0 -1
- package/dist/database/connection.d.ts +0 -40
- package/dist/database/connection.d.ts.map +0 -1
- package/dist/database/connection.js +0 -136
- package/dist/database/connection.js.map +0 -1
- package/dist/database/introspection.d.ts +0 -59
- package/dist/database/introspection.d.ts.map +0 -1
- package/dist/database/introspection.js +0 -124
- package/dist/database/introspection.js.map +0 -1
- package/dist/generators/markdown-generator.d.ts +0 -8
- package/dist/generators/markdown-generator.d.ts.map +0 -1
- package/dist/generators/markdown-generator.js +0 -106
- package/dist/generators/markdown-generator.js.map +0 -1
- package/dist/generators/sql-generator.d.ts +0 -20
- package/dist/generators/sql-generator.d.ts.map +0 -1
- package/dist/generators/sql-generator.js +0 -83
- package/dist/generators/sql-generator.js.map +0 -1
- package/dist/state/state-manager.d.ts +0 -95
- package/dist/state/state-manager.d.ts.map +0 -1
- package/dist/state/state-manager.js +0 -236
- package/dist/state/state-manager.js.map +0 -1
- package/dist/types/state-file.d.ts +0 -124
- package/dist/types/state-file.d.ts.map +0 -1
- package/dist/types/state-file.js +0 -79
- package/dist/types/state-file.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptEngine.js","sourceRoot":"","sources":["../../src/prompts/PromptEngine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"PromptEngine.js","sourceRoot":"","sources":["../../src/prompts/PromptEngine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,QAAQ,MAAM,U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AY;wBACrC,UAAU,EAAE,CAAC;qBACd,CAAC;gBACJ,CAAC;gBAED,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC3D,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;gBAEpC,iGAAiG;gBACjG,MAAM,MAAM,GAAG,iBAAiB,CAAI,OAAO,EAAE,IAAI,CAAC,CAAC;gBACnD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;oBACpB,OAAO;wBACL,OAAO,EAAE,KAAK;wBACd,YAAY,EAAE,kBAAkB;wBAChC,UAAU,EAAE,KAAK,EAAE,WAAW,IAAI,CAAC;qBACpC,CAAC;gBACJ,CAAC;gBACD,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,MAAM;oBACd,UAAU,EAAE,KAAK,EAAE,WAAW,IAAI,CAAC;oBACnC,IAAI,EAAE,KAAK,EAAE,IAAI;iBAClB,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qEAAqE;YACrE,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;gBACzB,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,8BAA+B,KAAe,CAAC,OAAO,EAAE;gBACtE,UAAU,EAAE,CAAC;aACd,CAAC,CAAC,CAAC;QACN,CAAC;IACH,CAAC;CACF"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Custom Nunjucks loader for file-based prompts
|
|
3
3
|
* Pattern adapted from Templates package's TemplateEntityLoader
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import nunjucks from 'nunjucks';
|
|
6
6
|
export declare class PromptFileLoader extends nunjucks.Loader {
|
|
7
7
|
private promptsDir;
|
|
8
8
|
async: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptFileLoader.d.ts","sourceRoot":"","sources":["../../src/prompts/PromptFileLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"PromptFileLoader.d.ts","sourceRoot":"","sources":["../../src/prompts/PromptFileLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,QAAQ,MAAM,UAAU,CAAC;AAIhC,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,MAAM;IAKvC,OAAO,CAAC,UAAU;IAJvB,KAAK,EAAE,IAAI,CAAQ;IAE1B,OAAO,CAAC,OAAO,CAAkC;gBAE7B,UAAU,EAAE,MAAM;IAItC;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAarC;;;OAGG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;CAYpD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Custom Nunjucks loader for file-based prompts
|
|
3
3
|
* Pattern adapted from Templates package's TemplateEntityLoader
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import nunjucks from 'nunjucks';
|
|
6
6
|
import * as fs from 'fs/promises';
|
|
7
7
|
import * as path from 'path';
|
|
8
8
|
export class PromptFileLoader extends nunjucks.Loader {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptFileLoader.js","sourceRoot":"","sources":["../../src/prompts/PromptFileLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"PromptFileLoader.js","sourceRoot":"","sources":["../../src/prompts/PromptFileLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,OAAO,gBAAiB,SAAQ,QAAQ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,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/db-auto-doc",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.2.0",
|
|
5
5
|
"description": "AI-powered database documentation generator for SQL Server, MySQL, and PostgreSQL. Analyzes your database structure, uses AI to generate comprehensive descriptions, and saves them as metadata. Works standalone - no MemberJunction runtime required.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"/bin",
|
|
36
|
-
"/dist"
|
|
36
|
+
"/dist",
|
|
37
|
+
"/prompts"
|
|
37
38
|
],
|
|
38
39
|
"scripts": {
|
|
39
40
|
"start": "ts-node-dev src/cli/cli.ts",
|
|
@@ -69,10 +70,10 @@
|
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
72
|
"@inquirer/prompts": "^8.2.0",
|
|
72
|
-
"@memberjunction/ai": "4.
|
|
73
|
-
"@memberjunction/ai-provider-bundle": "4.
|
|
74
|
-
"@memberjunction/core": "4.
|
|
75
|
-
"@memberjunction/global": "4.
|
|
73
|
+
"@memberjunction/ai": "4.2.0",
|
|
74
|
+
"@memberjunction/ai-provider-bundle": "4.2.0",
|
|
75
|
+
"@memberjunction/core": "4.2.0",
|
|
76
|
+
"@memberjunction/global": "4.2.0",
|
|
76
77
|
"@oclif/core": "^3.27.0",
|
|
77
78
|
"@oclif/plugin-help": "^6.2.37",
|
|
78
79
|
"chalk": "^5.6.2",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
You previously analyzed the table "{{ schemaName }}.{{ tableName }}" and generated this description:
|
|
2
|
+
|
|
3
|
+
**Current Description**: {{ currentDescription }}
|
|
4
|
+
|
|
5
|
+
**Reasoning**: {{ currentReasoning }}
|
|
6
|
+
|
|
7
|
+
**Confidence**: {{ currentConfidence }}
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## New Insights from Related Tables
|
|
12
|
+
|
|
13
|
+
We have since analyzed tables that reference or are referenced by this table, and discovered the following insights:
|
|
14
|
+
|
|
15
|
+
{{ insights }}
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Your Task
|
|
20
|
+
|
|
21
|
+
Based on these new insights from related tables, determine if you need to revise your understanding of this table.
|
|
22
|
+
|
|
23
|
+
Generate a JSON response with this exact structure:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"needsRevision": true,
|
|
28
|
+
"revisedDescription": "Updated description if needed",
|
|
29
|
+
"reasoning": "Explain what changed based on the new insights and why the revision is necessary",
|
|
30
|
+
"confidence": 0.98
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Guidelines:**
|
|
35
|
+
1. **Carefully evaluate** whether the new insights actually contradict or enhance your original understanding
|
|
36
|
+
2. **Set needsRevision to false** if:
|
|
37
|
+
- The insights are consistent with your current description
|
|
38
|
+
- The insights don't add meaningful new understanding
|
|
39
|
+
- The current description is still accurate
|
|
40
|
+
3. **Set needsRevision to true** if:
|
|
41
|
+
- The insights reveal the table serves a different purpose than originally thought
|
|
42
|
+
- Child/parent table analysis clarifies ambiguity
|
|
43
|
+
- The insights reveal relationships or usage patterns that change the meaning
|
|
44
|
+
4. **If revising**:
|
|
45
|
+
- Keep what was correct from the original description
|
|
46
|
+
- Integrate the new insights
|
|
47
|
+
- Explain clearly what changed and why
|
|
48
|
+
5. **Confidence**: Should generally be higher than original if insights clarify, lower if they introduce new ambiguity
|
|
49
|
+
|
|
50
|
+
**Important:**
|
|
51
|
+
- Don't revise just for the sake of revising
|
|
52
|
+
- Be precise about what specifically changed
|
|
53
|
+
- Reference the insights explicitly in your reasoning
|
|
54
|
+
|
|
55
|
+
Return ONLY valid JSON. Do not include markdown code fences or explanatory text.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
You are determining whether the database documentation analysis has converged (is complete and stable).
|
|
2
|
+
|
|
3
|
+
## Analysis Status
|
|
4
|
+
|
|
5
|
+
- **Schemas Analyzed**: {{ schemaCount }}
|
|
6
|
+
- **Tables Analyzed**: {{ tableCount }}
|
|
7
|
+
- **Iterations Performed**: {{ iterationCount }}
|
|
8
|
+
- **Average Confidence**: {{ averageConfidence | round(2) }}
|
|
9
|
+
|
|
10
|
+
## Recent Changes (Last Iteration)
|
|
11
|
+
|
|
12
|
+
{% if recentChanges and recentChanges.length > 0 %}
|
|
13
|
+
{% for change in recentChanges %}
|
|
14
|
+
- **{{ change.table }}**: {{ change.changeType }} (confidence: {{ change.confidence | round(2) }})
|
|
15
|
+
- Before: {{ change.before | truncate(100) }}
|
|
16
|
+
- After: {{ change.after | truncate(100) }}
|
|
17
|
+
{% endfor %}
|
|
18
|
+
{% else %}
|
|
19
|
+
No changes in the last iteration.
|
|
20
|
+
{% endif %}
|
|
21
|
+
|
|
22
|
+
## Low-Confidence Tables
|
|
23
|
+
|
|
24
|
+
{% if lowConfidenceTables and lowConfidenceTables.length > 0 %}
|
|
25
|
+
Tables below confidence threshold ({{ confidenceThreshold }}):
|
|
26
|
+
{% for table in lowConfidenceTables %}
|
|
27
|
+
- **{{ table.name }}** (confidence: {{ table.confidence | round(2) }})
|
|
28
|
+
- Description: {{ table.description | truncate(150) }}
|
|
29
|
+
- Reason: {{ table.reasoning | truncate(150) }}
|
|
30
|
+
{% endfor %}
|
|
31
|
+
{% else %}
|
|
32
|
+
All tables meet or exceed the confidence threshold.
|
|
33
|
+
{% endif %}
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Your Task
|
|
38
|
+
|
|
39
|
+
Determine if the analysis has converged or if further iterations are needed.
|
|
40
|
+
|
|
41
|
+
Generate a JSON response with this exact structure:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"hasConverged": true,
|
|
46
|
+
"reasoning": "Explain why you believe analysis is complete or needs more work. Reference specific evidence from above.",
|
|
47
|
+
"recommendedActions": [
|
|
48
|
+
"If hasConverged is false, suggest specific actions",
|
|
49
|
+
"Examples: 'Re-analyze Table X with additional context', 'Gather more sample data for Table Y'"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Guidelines:**
|
|
55
|
+
|
|
56
|
+
**Set hasConverged to TRUE if:**
|
|
57
|
+
1. No changes occurred in the last iteration
|
|
58
|
+
2. All tables have confidence >= threshold
|
|
59
|
+
3. No obvious contradictions or inconsistencies remain
|
|
60
|
+
4. The documentation appears complete and stable
|
|
61
|
+
|
|
62
|
+
**Set hasConverged to FALSE if:**
|
|
63
|
+
1. Recent changes suggest understanding is still evolving
|
|
64
|
+
2. Multiple tables have low confidence scores
|
|
65
|
+
3. Contradictions exist that might resolve with more iteration
|
|
66
|
+
4. Key relationships are unclear
|
|
67
|
+
|
|
68
|
+
**Reasoning should include:**
|
|
69
|
+
- Reference to stability (changes vs no changes)
|
|
70
|
+
- Assessment of confidence levels
|
|
71
|
+
- Evaluation of completeness
|
|
72
|
+
- Any remaining concerns
|
|
73
|
+
|
|
74
|
+
**Recommended Actions (if not converged):**
|
|
75
|
+
- Be specific about which tables need attention
|
|
76
|
+
- Suggest concrete steps for improvement
|
|
77
|
+
- Prioritize actions by impact
|
|
78
|
+
|
|
79
|
+
Return ONLY valid JSON. Do not include markdown code fences or explanatory text.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
You are reviewing the relationships and coherence across multiple database schemas.
|
|
2
|
+
|
|
3
|
+
## Schemas
|
|
4
|
+
|
|
5
|
+
{% for schema in schemas %}
|
|
6
|
+
### {{ schema.name }}
|
|
7
|
+
**Description**: {{ schema.description }}
|
|
8
|
+
**Table Count**: {{ schema.tableCount }}
|
|
9
|
+
{% if schema.inferredPurpose %}**Purpose**: {{ schema.inferredPurpose }}{% endif %}
|
|
10
|
+
{% if schema.businessDomains %}**Business Domains**: {{ schema.businessDomains | join(', ') }}{% endif %}
|
|
11
|
+
|
|
12
|
+
{% endfor %}
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Your Task
|
|
17
|
+
|
|
18
|
+
Review the schema descriptions for cross-schema patterns, relationships, and global insights.
|
|
19
|
+
|
|
20
|
+
Generate a JSON response with this exact structure:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"insights": [
|
|
25
|
+
"Observations about how schemas relate to each other",
|
|
26
|
+
"Patterns that emerge across multiple schemas",
|
|
27
|
+
"Potential organizational structure insights"
|
|
28
|
+
],
|
|
29
|
+
"globalPatterns": [
|
|
30
|
+
"Common naming conventions",
|
|
31
|
+
"Shared architectural patterns",
|
|
32
|
+
"Repeated design patterns"
|
|
33
|
+
],
|
|
34
|
+
"suggestions": [
|
|
35
|
+
"Recommendations for schema organization",
|
|
36
|
+
"Opportunities for consolidation or clarification",
|
|
37
|
+
"Potential documentation improvements"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Guidelines:**
|
|
43
|
+
1. **Insights**: Focus on:
|
|
44
|
+
- How schemas work together
|
|
45
|
+
- Logical separation of concerns
|
|
46
|
+
- Dependencies between schemas
|
|
47
|
+
2. **Global Patterns**: Identify:
|
|
48
|
+
- Consistent naming conventions
|
|
49
|
+
- Architectural patterns (e.g., audit schemas, lookup schemas, transactional schemas)
|
|
50
|
+
- Design principles evident across schemas
|
|
51
|
+
3. **Suggestions**: Provide:
|
|
52
|
+
- High-level organizational recommendations
|
|
53
|
+
- Opportunities for improved clarity
|
|
54
|
+
- Potential refactoring or consolidation ideas
|
|
55
|
+
|
|
56
|
+
**Important:**
|
|
57
|
+
- Focus on the big picture, not individual tables
|
|
58
|
+
- Look for system-wide patterns
|
|
59
|
+
- Consider the database as a whole
|
|
60
|
+
|
|
61
|
+
Return ONLY valid JSON. Do not include markdown code fences or explanatory text.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
You are reviewing multiple database schemas to ensure consistency in terminology, relationship descriptions, and business concept definitions across the entire database.
|
|
2
|
+
|
|
3
|
+
## Database: {{ databaseName }}
|
|
4
|
+
|
|
5
|
+
Total schemas: {{ schemaCount }}
|
|
6
|
+
|
|
7
|
+
### Schemas Overview
|
|
8
|
+
|
|
9
|
+
{% for schema in schemas %}
|
|
10
|
+
## Schema: {{ schema.name }}
|
|
11
|
+
|
|
12
|
+
**Description**: {{ schema.description }}
|
|
13
|
+
**Business Domains**: {{ schema.businessDomains }}
|
|
14
|
+
**Table Count**: {{ schema.tableCount }}
|
|
15
|
+
|
|
16
|
+
### Representative Tables
|
|
17
|
+
{% for table in schema.representativeTables %}
|
|
18
|
+
- **{{ table.name }}**: {{ table.description }}
|
|
19
|
+
{% endfor %}
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
{% endfor %}
|
|
24
|
+
|
|
25
|
+
## Shared/Cross-Schema Tables
|
|
26
|
+
|
|
27
|
+
The following tables appear in multiple schemas or have cross-schema relationships:
|
|
28
|
+
|
|
29
|
+
{% for table in crossSchemaTables %}
|
|
30
|
+
### {{ table.fullName }}
|
|
31
|
+
|
|
32
|
+
**Schemas**: {{ table.schemas }}
|
|
33
|
+
**Description**: {{ table.description }}
|
|
34
|
+
**Cross-Schema References**: {{ table.crossSchemaReferences }}
|
|
35
|
+
|
|
36
|
+
{% endfor %}
|
|
37
|
+
|
|
38
|
+
## Your Task
|
|
39
|
+
|
|
40
|
+
Perform a cross-schema consistency review and identify **MATERIAL** issues that affect understanding across the entire database.
|
|
41
|
+
|
|
42
|
+
Focus on:
|
|
43
|
+
|
|
44
|
+
1. **Terminology Consistency**: Are the same business concepts described consistently across schemas?
|
|
45
|
+
2. **Shared Table Consistency**: Are tables that span schemas described coherently?
|
|
46
|
+
3. **Cross-Schema Relationships**: Do relationships between schemas make logical sense?
|
|
47
|
+
4. **Business Domain Boundaries**: Are schema boundaries aligned with business domains?
|
|
48
|
+
5. **Naming Convention Conflicts**: Are similar concepts named differently in different schemas?
|
|
49
|
+
6. **Duplicate Concepts**: Are there tables in different schemas that appear to serve the same purpose?
|
|
50
|
+
|
|
51
|
+
## What Counts as MATERIAL
|
|
52
|
+
|
|
53
|
+
**MATERIAL issues** (flag these):
|
|
54
|
+
- Same business entity described differently in different schemas
|
|
55
|
+
- Contradictory relationship descriptions between schemas
|
|
56
|
+
- Shared tables with inconsistent purposes across schemas
|
|
57
|
+
- Critical cross-schema dependencies not properly documented
|
|
58
|
+
- Business domain misalignment that creates confusion
|
|
59
|
+
- Terminology that means different things in different schemas
|
|
60
|
+
|
|
61
|
+
**NOT material** (ignore these):
|
|
62
|
+
- Schema-specific implementation details
|
|
63
|
+
- Different levels of detail (if not contradictory)
|
|
64
|
+
- Stylistic variations
|
|
65
|
+
- Schema-specific business rules that don't contradict
|
|
66
|
+
- Minor naming differences that are schema-appropriate
|
|
67
|
+
|
|
68
|
+
## Response Format
|
|
69
|
+
|
|
70
|
+
Generate a JSON response with this exact structure:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"hasMaterialIssues": false,
|
|
75
|
+
"overallConsistency": "excellent | good | fair | poor",
|
|
76
|
+
"overallAssessment": "High-level summary of cross-schema consistency",
|
|
77
|
+
"crossSchemaIssues": [
|
|
78
|
+
{
|
|
79
|
+
"issueType": "terminology | shared_tables | relationships | business_domains | naming | duplication",
|
|
80
|
+
"severity": "high | medium | low",
|
|
81
|
+
"description": "Specific description of the cross-schema issue",
|
|
82
|
+
"affectedSchemas": ["Schema1", "Schema2"],
|
|
83
|
+
"affectedTables": [
|
|
84
|
+
{"schema": "Schema1", "table": "Table1"},
|
|
85
|
+
{"schema": "Schema2", "table": "Table2"}
|
|
86
|
+
],
|
|
87
|
+
"suggestedResolution": "How to resolve the inconsistency"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"terminologyConflicts": [
|
|
91
|
+
{
|
|
92
|
+
"term": "Term that has conflicts",
|
|
93
|
+
"usages": [
|
|
94
|
+
{
|
|
95
|
+
"schema": "Schema1",
|
|
96
|
+
"table": "Table1",
|
|
97
|
+
"meaning": "How it's used here"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"schema": "Schema2",
|
|
101
|
+
"table": "Table2",
|
|
102
|
+
"meaning": "Different meaning here"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"recommendedStandardization": "How the term should be used consistently"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"schemaIssues": [
|
|
109
|
+
{
|
|
110
|
+
"schemaName": "SchemaName",
|
|
111
|
+
"issueType": "description | business_domain | relationships",
|
|
112
|
+
"description": "What's wrong with this schema's documentation",
|
|
113
|
+
"suggestedFix": "How to correct it"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"databaseLevelObservations": [
|
|
117
|
+
{
|
|
118
|
+
"observation": "Broader insights about the entire database structure",
|
|
119
|
+
"impact": "How this affects understanding/usage",
|
|
120
|
+
"recommendation": "What should be done about it"
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Guidelines:**
|
|
127
|
+
- Set `hasMaterialIssues: true` ONLY if corrections are needed
|
|
128
|
+
- Focus on issues that create confusion across schema boundaries
|
|
129
|
+
- Identify terminology that needs standardization
|
|
130
|
+
- Highlight duplicate or overlapping functionality
|
|
131
|
+
- Consider whether schema boundaries align with business domains
|
|
132
|
+
|
|
133
|
+
Return ONLY valid JSON. Do not include markdown code fences or explanatory text.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
You are reviewing a group of database tables that were analyzed together at the same dependency level. Your task is to identify **MATERIAL** inconsistencies or logical issues in how these tables are described and related to each other.
|
|
2
|
+
|
|
3
|
+
## Dependency Level {{ dependencyLevel }}
|
|
4
|
+
|
|
5
|
+
These tables all have the same dependency level, meaning they depend on the same set of parent tables and are analyzed together as a cohesive group.
|
|
6
|
+
|
|
7
|
+
### Tables at This Level
|
|
8
|
+
|
|
9
|
+
{% for table in tables %}
|
|
10
|
+
#### {{ table.name }}
|
|
11
|
+
|
|
12
|
+
**Description**: {{ table.description }}
|
|
13
|
+
|
|
14
|
+
**Columns**:
|
|
15
|
+
{% for column in table.columns %}
|
|
16
|
+
- **{{ column.name }}** ({{ column.dataType }}): {{ column.description }}
|
|
17
|
+
{% endfor %}
|
|
18
|
+
|
|
19
|
+
**Depends On**:
|
|
20
|
+
{% for dep in table.dependsOn %}
|
|
21
|
+
- {{ dep.schema }}.{{ dep.table }} (via {{ dep.column }})
|
|
22
|
+
{% endfor %}
|
|
23
|
+
|
|
24
|
+
**Referenced By**:
|
|
25
|
+
{% for dep in table.dependents %}
|
|
26
|
+
- {{ dep.schema }}.{{ dep.table }}
|
|
27
|
+
{% endfor %}
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
{% endfor %}
|
|
32
|
+
|
|
33
|
+
## Your Task
|
|
34
|
+
|
|
35
|
+
Review these tables as a group and identify **MATERIAL** issues only. Focus on:
|
|
36
|
+
|
|
37
|
+
1. **Relationship Consistency**: Do foreign key descriptions align between parent and child tables?
|
|
38
|
+
2. **Business Logic Coherence**: Do the table descriptions make sense together as a group?
|
|
39
|
+
3. **Terminology Consistency**: Are similar concepts described using consistent terminology?
|
|
40
|
+
4. **Logical Contradictions**: Are there contradictions in how tables relate or what they represent?
|
|
41
|
+
5. **Missing Context**: Are there critical details missing that affect understanding of the group?
|
|
42
|
+
|
|
43
|
+
## What Counts as MATERIAL
|
|
44
|
+
|
|
45
|
+
**MATERIAL issues** (flag these):
|
|
46
|
+
- Contradictory descriptions of the same relationship
|
|
47
|
+
- Misidentified business purpose that affects other tables
|
|
48
|
+
- Missing critical information about how tables interact
|
|
49
|
+
- Incorrect understanding of cardinality or relationship types
|
|
50
|
+
- Terminology conflicts that create confusion (e.g., "member" means different things)
|
|
51
|
+
|
|
52
|
+
**NOT material** (ignore these):
|
|
53
|
+
- Minor wording differences
|
|
54
|
+
- Stylistic variations
|
|
55
|
+
- Different levels of detail that don't contradict
|
|
56
|
+
- Grammar or formatting issues
|
|
57
|
+
- Redundant information that's technically correct
|
|
58
|
+
|
|
59
|
+
## Response Format
|
|
60
|
+
|
|
61
|
+
Generate a JSON response with this exact structure:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"hasMaterialIssues": false,
|
|
66
|
+
"overallAssessment": "Brief summary of the dependency level's coherence",
|
|
67
|
+
"tableIssues": [
|
|
68
|
+
{
|
|
69
|
+
"tableName": "TableName",
|
|
70
|
+
"issueType": "relationship_inconsistency | business_logic | terminology | contradiction | missing_context",
|
|
71
|
+
"severity": "high | medium | low",
|
|
72
|
+
"description": "Specific description of the material issue",
|
|
73
|
+
"affectedTables": ["Table1", "Table2"],
|
|
74
|
+
"suggestedFix": "What should be corrected in the description"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"crossTableObservations": [
|
|
78
|
+
{
|
|
79
|
+
"observation": "Broader pattern or insight across multiple tables",
|
|
80
|
+
"tables": ["Table1", "Table2", "Table3"]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Guidelines:**
|
|
87
|
+
- Set `hasMaterialIssues: true` ONLY if you found material problems
|
|
88
|
+
- Be specific about which tables and descriptions need correction
|
|
89
|
+
- Focus on issues that would mislead someone trying to understand the database
|
|
90
|
+
- Group related issues together in crossTableObservations when appropriate
|
|
91
|
+
|
|
92
|
+
Return ONLY valid JSON. Do not include markdown code fences or explanatory text.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Fix Failed SQL Query
|
|
2
|
+
|
|
3
|
+
You are fixing a SQL query that failed validation. Your task is to analyze the error and provide a corrected version of the SQL.
|
|
4
|
+
|
|
5
|
+
## Original Query Plan
|
|
6
|
+
|
|
7
|
+
**Query ID:** {{ queryPlan.id }}
|
|
8
|
+
**Name:** {{ queryPlan.name }}
|
|
9
|
+
**Description:** {{ queryPlan.description }}
|
|
10
|
+
**Business Purpose:** {{ queryPlan.businessPurpose }}
|
|
11
|
+
**Type:** {{ queryPlan.queryType }}
|
|
12
|
+
**Pattern:** {{ queryPlan.queryPattern }}
|
|
13
|
+
**Complexity:** {{ queryPlan.complexity }}
|
|
14
|
+
|
|
15
|
+
{% if queryPlan.relatedQueryIds.length > 0 %}
|
|
16
|
+
**Related Queries:** {{ queryPlan.relatedQueryIds | join(', ') }}
|
|
17
|
+
{% endif %}
|
|
18
|
+
|
|
19
|
+
## Database Context
|
|
20
|
+
|
|
21
|
+
**Database Type:** {{ databaseType }}
|
|
22
|
+
**Schema:** {{ schemaName }}
|
|
23
|
+
|
|
24
|
+
### Primary Table: {{ focusTable }}
|
|
25
|
+
{{ tableInfo.description }}
|
|
26
|
+
|
|
27
|
+
**Columns:**
|
|
28
|
+
{% for col in tableInfo.columns %}
|
|
29
|
+
- **{{ col.name }}** ({{ col.dataType }}){% if col.isPrimaryKey %} [PK]{% endif %}{% if col.isForeignKey %} [FK → {{ col.foreignKeyReferences.referencesTable }}]{% endif %}
|
|
30
|
+
{% if col.description %}{{ col.description }}{% endif %}
|
|
31
|
+
{% if col.possibleValues %}Values: {{ col.possibleValues | jsoninline }}{% endif %}
|
|
32
|
+
{% endfor %}
|
|
33
|
+
|
|
34
|
+
{% if relatedTables.length > 0 %}
|
|
35
|
+
### Related Tables
|
|
36
|
+
{% for table in relatedTables %}
|
|
37
|
+
**{{ table.name }}** ({{ table.rowCount }} rows)
|
|
38
|
+
{% if table.description %}{{ table.description }}{% endif %}
|
|
39
|
+
|
|
40
|
+
Columns:
|
|
41
|
+
{% for col in table.columns %}
|
|
42
|
+
- {{ col.name }} ({{ col.dataType }}){% if col.isPrimaryKey %} [PK]{% endif %}
|
|
43
|
+
{% endfor %}
|
|
44
|
+
|
|
45
|
+
{% endfor %}
|
|
46
|
+
{% endif %}
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Failed Query
|
|
51
|
+
|
|
52
|
+
### Current SQL
|
|
53
|
+
```sql
|
|
54
|
+
{{ currentSQL }}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Error Message
|
|
58
|
+
```
|
|
59
|
+
{{ errorMessage }}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
{% if attemptNumber > 1 %}
|
|
63
|
+
### Previous Fix Attempts
|
|
64
|
+
This is attempt {{ attemptNumber }} of {{ maxAttempts }}.
|
|
65
|
+
|
|
66
|
+
{% for attempt in previousAttempts %}
|
|
67
|
+
**Attempt {{ loop.index }}:**
|
|
68
|
+
```sql
|
|
69
|
+
{{ attempt.sql }}
|
|
70
|
+
```
|
|
71
|
+
Error: `{{ attempt.error }}`
|
|
72
|
+
|
|
73
|
+
{% endfor %}
|
|
74
|
+
{% endif %}
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Task
|
|
79
|
+
|
|
80
|
+
Analyze the error and provide a corrected SQL query that:
|
|
81
|
+
1. Fixes the specific error mentioned above
|
|
82
|
+
2. Maintains the original business purpose and query intent
|
|
83
|
+
3. Uses correct column names and data types from the schema
|
|
84
|
+
4. Is valid and executable against {{ databaseType }}
|
|
85
|
+
|
|
86
|
+
### Common Issues to Check
|
|
87
|
+
- **Column name errors**: Verify column names match the schema exactly (case-sensitive)
|
|
88
|
+
- **Table name errors**: Check table names and aliases are correct
|
|
89
|
+
- **Data type mismatches**: Ensure comparisons use compatible types
|
|
90
|
+
- **Syntax errors**: Fix SQL syntax for {{ databaseType }}
|
|
91
|
+
- **Missing joins**: Add required joins if referencing multiple tables
|
|
92
|
+
- **Aggregation errors**: Ensure all non-aggregated columns are in GROUP BY
|
|
93
|
+
- **Parameter syntax**: Use `@ParameterName` format for {{ databaseType }}
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Output Format
|
|
98
|
+
|
|
99
|
+
Return a JSON object with the corrected query:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"sqlQuery": "SELECT ...",
|
|
104
|
+
"parameters": [
|
|
105
|
+
{
|
|
106
|
+
"name": "ParameterName",
|
|
107
|
+
"dataType": "VARCHAR|INT|DATE|...",
|
|
108
|
+
"description": "What this parameter controls",
|
|
109
|
+
"required": true,
|
|
110
|
+
"defaultValue": "DefaultIfAny",
|
|
111
|
+
"exampleValues": ["Example1", "Example2", "Example3"]
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"sampleResultColumns": [
|
|
115
|
+
{
|
|
116
|
+
"name": "ColumnName",
|
|
117
|
+
"dataType": "VARCHAR|INT|DECIMAL|...",
|
|
118
|
+
"description": "What this column contains",
|
|
119
|
+
"isMeasure": false,
|
|
120
|
+
"isDimension": true
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"filteringRules": [
|
|
124
|
+
"Explicit rule about how filtering works in this query"
|
|
125
|
+
],
|
|
126
|
+
"aggregationRules": [
|
|
127
|
+
"Explicit rule about how aggregation works (if applicable)"
|
|
128
|
+
],
|
|
129
|
+
"joinRules": [
|
|
130
|
+
"Explicit rule about how tables are joined (if applicable)"
|
|
131
|
+
],
|
|
132
|
+
"alignmentNotes": "How this query's filtering logic aligns with related queries (if relatedQueryIds exist)",
|
|
133
|
+
"fixExplanation": "Brief explanation of what was wrong and how it was fixed"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**IMPORTANT:**
|
|
138
|
+
- The corrected SQL must be valid and executable against {{ databaseType }}
|
|
139
|
+
- All JSON must be valid and parseable
|
|
140
|
+
- Use actual column names from the schema above
|
|
141
|
+
- The fix must address the specific error while preserving the query's business purpose
|