@mriekki/lean 0.4.1 → 0.4.3
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/assets/components.json +3 -3
- package/assets/core/distribution.json +3 -0
- package/assets/generated/ASSEMBLY.json +24 -9
- package/assets/generated/core/core/learning/ENGINEERING_LEARNING_WORKBOOK.md +4 -1
- package/assets/generated/core/core/learning/LEARNING_MAP.md +22 -0
- package/assets/generated/core/core/learning/SQL_DRILLS.md +80 -17
- package/assets/generated/core/core/process/COACHING_GUIDE.md +3 -1
- package/assets/generated/core/core/process/DATABASE_LEARNING_WORKBENCH.md +346 -0
- package/assets/generated/core/core/skills/coach/SKILL.md +12 -1
- package/assets/generated/core/core/skills/db-lab/SKILL.md +202 -0
- package/assets/generated/core/tools/db_lab/sqlite_workbench.py +463 -0
- package/assets/generated/deployment/src/lean_poc_deployment/registry_access.py +2 -0
- package/package.json +1 -1
package/assets/components.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"package": "@mriekki/lean",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"defaultProfile": "greenfield-poc",
|
|
6
6
|
"profiles": {
|
|
7
7
|
"greenfield-poc": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"components": {
|
|
15
15
|
"core": {
|
|
16
16
|
"repository": "mriekki/lean-agentic-core",
|
|
17
|
-
"commit": "
|
|
17
|
+
"commit": "1420caf15d5c078af8800f35966b47836b6da99f",
|
|
18
18
|
"version": "1.13.0",
|
|
19
19
|
"distribution": "greenfield-workspace",
|
|
20
20
|
"descriptor": "assets/core/distribution.json",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"deployment": {
|
|
25
25
|
"repository": "mriekki/lean-poc-deployment-kit",
|
|
26
|
-
"commit": "
|
|
26
|
+
"commit": "2763e604c20e64720d7de71fa93a88d99677be36",
|
|
27
27
|
"distribution": "greenfield-poc",
|
|
28
28
|
"descriptor": "assets/deployment/distribution.json",
|
|
29
29
|
"sourceRoot": "assets/generated/deployment",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
{"source":"core/skills/deploy/SKILL.md","destination":".github/skills/deploy/SKILL.md"},
|
|
25
25
|
{"source":"core/skills/tear-down/SKILL.md","destination":".github/skills/tear-down/SKILL.md"},
|
|
26
26
|
{"source":"core/skills/coach/SKILL.md","destination":".github/skills/coach/SKILL.md"},
|
|
27
|
+
{"source":"core/skills/db-lab/SKILL.md","destination":".github/skills/db-lab/SKILL.md"},
|
|
27
28
|
{"source":"core/skills/code-walkthrough/SKILL.md","destination":".github/skills/code-walkthrough/SKILL.md"},
|
|
28
29
|
{"source":"core/skills/learning-review/SKILL.md","destination":".github/skills/learning-review/SKILL.md"},
|
|
29
30
|
{"source":"core/process/WORK_ITEM_MODEL.md","destination":"docs/process/WORK_ITEM_MODEL.md"},
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
{"source":"core/process/GUIDED_NEXT_STEPS.md","destination":"docs/process/GUIDED_NEXT_STEPS.md"},
|
|
34
35
|
{"source":"core/process/INTERACTIVE_SESSION_GUIDE.md","destination":"docs/process/INTERACTIVE_SESSION_GUIDE.md"},
|
|
35
36
|
{"source":"core/process/COACHING_GUIDE.md","destination":"docs/process/COACHING_GUIDE.md"},
|
|
37
|
+
{"source":"core/process/DATABASE_LEARNING_WORKBENCH.md","destination":"docs/process/DATABASE_LEARNING_WORKBENCH.md"},
|
|
36
38
|
{"source":"core/process/SETUP_ACCEPTANCE_CHECKLIST.md","destination":"docs/process/SETUP_ACCEPTANCE_CHECKLIST.md"},
|
|
37
39
|
{"source":"core/templates/PULL_REQUEST_TEMPLATE.md","destination":".github/PULL_REQUEST_TEMPLATE.md"},
|
|
38
40
|
{"source":"core/templates/PRODUCT_BRIEF_TEMPLATE.md","destination":"docs/templates/PRODUCT_BRIEF_TEMPLATE.md"},
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
{"source":"core/learning/SYSTEM_DESIGN_DRILLS.md","destination":"learning/SYSTEM_DESIGN_DRILLS.md"},
|
|
47
49
|
{"source":"core/learning/DIAGRAM_GUIDE.md","destination":"learning/DIAGRAM_GUIDE.md"},
|
|
48
50
|
{"source":"core/learning/RESOURCE_CATALOG.md","destination":"learning/RESOURCE_CATALOG.md"},
|
|
51
|
+
{"source":"tools/db_lab/sqlite_workbench.py","destination":"tools/lean-db-lab/sqlite-workbench.py"},
|
|
49
52
|
{"source":"tools/package/check_baseline.py","destination":"tools/lean-core/check-core-baseline.py"},
|
|
50
53
|
{"source":"tools/package/check_upstream.py","destination":"tools/lean-core/check-core-upstream.py"}
|
|
51
54
|
]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"package": "@mriekki/lean",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"components": {
|
|
6
6
|
"core": {
|
|
7
7
|
"repository": "mriekki/lean-agentic-core",
|
|
8
|
-
"commit": "
|
|
8
|
+
"commit": "1420caf15d5c078af8800f35966b47836b6da99f",
|
|
9
9
|
"version": "1.13.0",
|
|
10
10
|
"distribution": "greenfield-workspace",
|
|
11
11
|
"files": [
|
|
@@ -117,7 +117,12 @@
|
|
|
117
117
|
{
|
|
118
118
|
"source": "core/skills/coach/SKILL.md",
|
|
119
119
|
"destination": ".github/skills/coach/SKILL.md",
|
|
120
|
-
"sha256": "
|
|
120
|
+
"sha256": "9a15c5876b6dcaaa5157c65c28f797302bd3f869048261f0d070904713b239e7"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"source": "core/skills/db-lab/SKILL.md",
|
|
124
|
+
"destination": ".github/skills/db-lab/SKILL.md",
|
|
125
|
+
"sha256": "6c7868002b7408215e20807a427213b1d5a15473379c91396e8757a50a1be947"
|
|
121
126
|
},
|
|
122
127
|
{
|
|
123
128
|
"source": "core/skills/code-walkthrough/SKILL.md",
|
|
@@ -162,7 +167,12 @@
|
|
|
162
167
|
{
|
|
163
168
|
"source": "core/process/COACHING_GUIDE.md",
|
|
164
169
|
"destination": "docs/process/COACHING_GUIDE.md",
|
|
165
|
-
"sha256": "
|
|
170
|
+
"sha256": "afe5d77028768d5a2d47cad94dc3436f368b94c22d87fe9a36fa0fdcaa5c461f"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"source": "core/process/DATABASE_LEARNING_WORKBENCH.md",
|
|
174
|
+
"destination": "docs/process/DATABASE_LEARNING_WORKBENCH.md",
|
|
175
|
+
"sha256": "8db2008cce0fd1b63aea27c1e47ab2c96ad380a2f80cc9be1743c3961d86d0a7"
|
|
166
176
|
},
|
|
167
177
|
{
|
|
168
178
|
"source": "core/process/SETUP_ACCEPTANCE_CHECKLIST.md",
|
|
@@ -192,12 +202,12 @@
|
|
|
192
202
|
{
|
|
193
203
|
"source": "core/learning/ENGINEERING_LEARNING_WORKBOOK.md",
|
|
194
204
|
"destination": "learning/ENGINEERING_LEARNING_WORKBOOK.md",
|
|
195
|
-
"sha256": "
|
|
205
|
+
"sha256": "e46909fe4b88cf1b617b9eb1f9b8cd1d78b9332e9c8825bd6e6021aadcd99552"
|
|
196
206
|
},
|
|
197
207
|
{
|
|
198
208
|
"source": "core/learning/LEARNING_MAP.md",
|
|
199
209
|
"destination": "learning/LEARNING_MAP.md",
|
|
200
|
-
"sha256": "
|
|
210
|
+
"sha256": "172385b97c4fd41c08bc5344e29d026e48950b7bf98e9225288ab254b51ea9e0"
|
|
201
211
|
},
|
|
202
212
|
{
|
|
203
213
|
"source": "core/learning/LEARNING_PROGRESS.md",
|
|
@@ -212,7 +222,7 @@
|
|
|
212
222
|
{
|
|
213
223
|
"source": "core/learning/SQL_DRILLS.md",
|
|
214
224
|
"destination": "learning/SQL_DRILLS.md",
|
|
215
|
-
"sha256": "
|
|
225
|
+
"sha256": "696b9c97d3c1bd7adc7be1a43dcd655056bbf55ab58bc7741c59225d52f8c239"
|
|
216
226
|
},
|
|
217
227
|
{
|
|
218
228
|
"source": "core/learning/SYSTEM_DESIGN_DRILLS.md",
|
|
@@ -229,6 +239,11 @@
|
|
|
229
239
|
"destination": "learning/RESOURCE_CATALOG.md",
|
|
230
240
|
"sha256": "88fc894dd51da7280aabd3df439bcbda337f437ece43640d86dfc0842dd0f91e"
|
|
231
241
|
},
|
|
242
|
+
{
|
|
243
|
+
"source": "tools/db_lab/sqlite_workbench.py",
|
|
244
|
+
"destination": "tools/lean-db-lab/sqlite-workbench.py",
|
|
245
|
+
"sha256": "a5bb99a3f67f88f00b99c10b2c0698710b6b2fa302becc6ff3435c4321cdd4d3"
|
|
246
|
+
},
|
|
232
247
|
{
|
|
233
248
|
"source": "tools/package/check_baseline.py",
|
|
234
249
|
"destination": "tools/lean-core/check-core-baseline.py",
|
|
@@ -243,7 +258,7 @@
|
|
|
243
258
|
},
|
|
244
259
|
"deployment": {
|
|
245
260
|
"repository": "mriekki/lean-poc-deployment-kit",
|
|
246
|
-
"commit": "
|
|
261
|
+
"commit": "2763e604c20e64720d7de71fa93a88d99677be36",
|
|
247
262
|
"distribution": "greenfield-poc",
|
|
248
263
|
"files": [
|
|
249
264
|
{
|
|
@@ -324,7 +339,7 @@
|
|
|
324
339
|
{
|
|
325
340
|
"source": "src/lean_poc_deployment/registry_access.py",
|
|
326
341
|
"destination": "tools/lean-deployment/lean_poc_deployment/registry_access.py",
|
|
327
|
-
"sha256": "
|
|
342
|
+
"sha256": "5815a1921ecf37dc395f9c68b1ebda2b17dd6a44620b2356d1adff5df44c4382"
|
|
328
343
|
},
|
|
329
344
|
{
|
|
330
345
|
"source": "src/lean_poc_deployment/registry_cli.py",
|
|
@@ -12,10 +12,13 @@ Use the learning tools for different purposes:
|
|
|
12
12
|
/code-walkthrough — instructional walkthrough of actual implementation changes
|
|
13
13
|
/learning-review — assessment of whether the developer can explain and defend the implementation
|
|
14
14
|
/coach — targeted concept learning, debugging practice, design discussion, drills, and deeper follow-up
|
|
15
|
+
/db-lab — evidence-backed database/schema/ORM/query-plan exploration and database interview practice
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
All learning activity is optional and never an engineering delivery gate.
|
|
18
19
|
|
|
20
|
+
For database usage examples, see `docs/process/DATABASE_LEARNING_WORKBENCH.md` in a greenfield consumer.
|
|
21
|
+
|
|
19
22
|
## Preferred project-first sequence
|
|
20
23
|
|
|
21
24
|
When an implementation is stable enough to study, a useful optional sequence is:
|
|
@@ -24,7 +27,7 @@ When an implementation is stable enough to study, a useful optional sequence is:
|
|
|
24
27
|
implementation
|
|
25
28
|
→ /code-walkthrough
|
|
26
29
|
→ /learning-review
|
|
27
|
-
→ targeted /coach follow-up where gaps remain
|
|
30
|
+
→ targeted /coach or /db-lab follow-up where gaps remain
|
|
28
31
|
```
|
|
29
32
|
|
|
30
33
|
A code walkthrough should connect two views of every meaningful change:
|
|
@@ -28,6 +28,26 @@ L5 Defend / Design
|
|
|
28
28
|
L6 Interview Ready
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
## Database learning is multi-dimensional
|
|
32
|
+
|
|
33
|
+
Do not reduce database learning to one "SQL" level. When database depth matters, assess the relevant areas independently:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
relational modeling
|
|
37
|
+
keys + integrity constraints
|
|
38
|
+
normalization + anomalies
|
|
39
|
+
SQL query construction
|
|
40
|
+
indexes + access patterns
|
|
41
|
+
query plans + performance reasoning
|
|
42
|
+
transactions + concurrency
|
|
43
|
+
ORM translation
|
|
44
|
+
schema evolution + migrations
|
|
45
|
+
database debugging
|
|
46
|
+
design defense / interview communication
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Use `/db-lab` for evidence-backed exploration of the current project's schema, queries, ORM translation, query plans, migrations, and query-to-ERD relationships. Use `/coach` for adaptive teaching and reinforcement.
|
|
50
|
+
|
|
31
51
|
## How real-code learning maps to the levels
|
|
32
52
|
|
|
33
53
|
A structured `/code-walkthrough` is especially useful for the first three levels:
|
|
@@ -46,6 +66,8 @@ L5 Defend / Design — explain choices, alternatives, tradeoffs, and architectur
|
|
|
46
66
|
L6 Interview Ready — explain the implementation clearly under follow-up questioning
|
|
47
67
|
```
|
|
48
68
|
|
|
69
|
+
For database work, L4-L6 should include evidence-based reasoning about schema choices, constraints, access patterns, indexes/plans, transactions, ORM behavior, migration safety, and credible alternatives where relevant.
|
|
70
|
+
|
|
49
71
|
Use `/learning-review` to assess understanding after a walkthrough. Use `/coach` for targeted reinforcement, practice, or deeper exploration. These activities are optional and do not affect engineering delivery state.
|
|
50
72
|
|
|
51
73
|
Coach should recommend only a small number of next topics based on the actual repository/work item.
|
|
@@ -1,27 +1,90 @@
|
|
|
1
|
-
# SQL / Database Drills
|
|
1
|
+
# SQL / Database Learning and Drills
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use the actual repository and domain whenever possible. SQL syntax is only one database competency; do not let query fluency hide weak relational design, indexing, transaction, or ORM reasoning.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
- aggregates,
|
|
7
|
-
- GROUP BY/HAVING,
|
|
8
|
-
- pagination,
|
|
9
|
-
- deterministic sorting,
|
|
10
|
-
- indexes,
|
|
11
|
-
- query plans,
|
|
12
|
-
- constraints,
|
|
13
|
-
- transactions,
|
|
14
|
-
- concurrency,
|
|
15
|
-
- N+1,
|
|
16
|
-
- ORM translation.
|
|
5
|
+
For evidence-backed hands-on exploration use `/db-lab`. For adaptive explanation, questioning, and reinforcement use `/coach`.
|
|
17
6
|
|
|
18
|
-
|
|
7
|
+
## Competencies
|
|
8
|
+
|
|
9
|
+
Assess independently using the common L1-L6 learning levels:
|
|
10
|
+
|
|
11
|
+
- relational modeling and cardinality;
|
|
12
|
+
- primary/foreign/candidate keys and integrity constraints;
|
|
13
|
+
- normalization, anomalies, and deliberate denormalization;
|
|
14
|
+
- query construction: joins, aggregates, GROUP BY/HAVING, subqueries/CTEs, pagination, deterministic sorting;
|
|
15
|
+
- indexes and access-pattern reasoning;
|
|
16
|
+
- query-plan interpretation and performance diagnosis;
|
|
17
|
+
- transactions, isolation, concurrency, and failure behavior;
|
|
18
|
+
- ORM translation, N+1 behavior, tracking/materialization, and abstraction leaks;
|
|
19
|
+
- schema evolution and migration safety;
|
|
20
|
+
- database debugging;
|
|
21
|
+
- design defense and interview communication.
|
|
22
|
+
|
|
23
|
+
## Query drill
|
|
19
24
|
|
|
20
25
|
```text
|
|
21
26
|
problem
|
|
22
|
-
→ developer writes SQL
|
|
27
|
+
→ developer writes/predicts SQL
|
|
23
28
|
→ correctness
|
|
24
29
|
→ edge cases
|
|
30
|
+
→ access pattern
|
|
25
31
|
→ indexing/query-plan follow-up
|
|
26
|
-
→ ORM
|
|
32
|
+
→ ORM translation when useful
|
|
33
|
+
→ interview-style defense when useful
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Do not reveal the complete query immediately unless the developer asks for explanation-first teaching.
|
|
37
|
+
|
|
38
|
+
## Design drill
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
requirements
|
|
42
|
+
→ entities
|
|
43
|
+
→ relationships/cardinality
|
|
44
|
+
→ keys
|
|
45
|
+
→ constraints
|
|
46
|
+
→ normalization
|
|
47
|
+
→ expected queries
|
|
48
|
+
→ indexes
|
|
49
|
+
→ transactions/concurrency
|
|
50
|
+
→ migration/evolution concerns
|
|
51
|
+
→ defend tradeoffs
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Prefer practical anomaly questions over memorized normalization definitions.
|
|
55
|
+
|
|
56
|
+
## Debugging drill
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
symptom
|
|
60
|
+
→ hypotheses
|
|
61
|
+
→ SQL + parameters
|
|
62
|
+
→ plan / constraints / transaction evidence
|
|
63
|
+
→ root cause
|
|
64
|
+
→ fix concept
|
|
65
|
+
→ prevention
|
|
27
66
|
```
|
|
67
|
+
|
|
68
|
+
Use provider-native plan evidence where available and distinguish candidate indexes from indexes actually selected by the planner.
|
|
69
|
+
|
|
70
|
+
## ORM drill
|
|
71
|
+
|
|
72
|
+
Trace both directions:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
ORM/LINQ expression → generated/captured SQL → plan → result materialization
|
|
76
|
+
SQL/schema constraint → ORM behavior/error → application-visible effect
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
When a framework exposes both a translation preview and actual executed commands, keep them distinct.
|
|
80
|
+
|
|
81
|
+
## Suggested interview prompts
|
|
82
|
+
|
|
83
|
+
- Model a many-to-many relationship that later needs attributes on the relationship itself.
|
|
84
|
+
- Explain where uniqueness, nullability, and referential-integrity rules should be enforced.
|
|
85
|
+
- Given three common queries, design only the indexes you can justify.
|
|
86
|
+
- Diagnose why a query performs a scan instead of the expected indexed search.
|
|
87
|
+
- Explain an N+1 problem and two credible fixes with tradeoffs.
|
|
88
|
+
- Design a safe migration from nullable to required data.
|
|
89
|
+
- Define a transaction boundary for a multi-table operation and discuss concurrency failure modes.
|
|
90
|
+
- Defend when a surrogate key is preferable to a natural/composite key and when it is not.
|
|
@@ -33,6 +33,8 @@ For a structured walkthrough of an implementation change set, use `/code-walkthr
|
|
|
33
33
|
|
|
34
34
|
Use `/coach` for broader or ad-hoc concept learning. Use `/learning-review` when the primary goal is to assess whether the developer can explain and defend what was built.
|
|
35
35
|
|
|
36
|
+
For hands-on database learning, `/db-lab` is the evidence-backed companion to Coach. Coach can teach database concepts, probe gaps, and run interview drills; Database Lab inspects the actual project schema/ORM/query/migration/query-plan evidence and can drive query-to-ERD highlighting when an interactive workbench is installed. See `DATABASE_LEARNING_WORKBENCH.md` for quick-start commands and examples.
|
|
37
|
+
|
|
36
38
|
## Levels
|
|
37
39
|
|
|
38
40
|
```text
|
|
@@ -49,7 +51,7 @@ A useful optional sequence after stable implementation is:
|
|
|
49
51
|
```text
|
|
50
52
|
code walkthrough
|
|
51
53
|
→ learning review
|
|
52
|
-
→ targeted coaching as needed
|
|
54
|
+
→ targeted coaching / database lab as needed
|
|
53
55
|
```
|
|
54
56
|
|
|
55
57
|
None of those learning activities is an engineering delivery gate.
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Database Learning Workbench
|
|
2
|
+
|
|
3
|
+
The Database Learning Workbench is the reusable Lean learning contract behind `/db-lab`. It makes database behavior that frameworks and ORMs often hide visible enough to inspect, explain, debug, and defend.
|
|
4
|
+
|
|
5
|
+
It is project-aware rather than a generic SQL course: use the current repository's domain, schema, migrations, ORM mappings, queries, and safe development/test database evidence as the curriculum.
|
|
6
|
+
|
|
7
|
+
Learning remains optional and never changes engineering delivery state.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
Use `/coach` for explanation, adaptive questioning, and gap assessment. Use `/db-lab` when the learning needs concrete database evidence.
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
/coach database design
|
|
15
|
+
/db-lab schema
|
|
16
|
+
/db-lab trace <query/file/symbol>
|
|
17
|
+
/db-lab plan <query>
|
|
18
|
+
/db-lab debug <symptom/query>
|
|
19
|
+
/db-lab migration <migration>
|
|
20
|
+
/db-lab interview database
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Natural-language arguments are preferred over rigid syntax. Examples:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
/db-lab show me how Recipes and Ingredients are related
|
|
27
|
+
/db-lab trace the EF query used by GetWeeklyMealPlan
|
|
28
|
+
/db-lab why is this query scanning MealPlanItems
|
|
29
|
+
/db-lab show which indexes this query actually uses
|
|
30
|
+
/db-lab walk me through the latest migration without applying it
|
|
31
|
+
/db-lab give me a database-design interview based on this domain
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## SQLite interactive workbench — V1
|
|
35
|
+
|
|
36
|
+
Greenfield consumers that include the Core learning payload receive:
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
tools/lean-db-lab/sqlite-workbench.py
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The tool is dependency-free Python and opens SQLite databases read-only. It generates a self-contained interactive `index.html` and a machine-readable `workbench.json`.
|
|
43
|
+
|
|
44
|
+
### PowerShell example
|
|
45
|
+
|
|
46
|
+
From the repository root, using a known development/test SQLite file:
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
$out = Join-Path $env:TEMP "lean-db-lab"
|
|
50
|
+
python .\tools\lean-db-lab\sqlite-workbench.py export `
|
|
51
|
+
--db .\.data\app.db `
|
|
52
|
+
--out $out
|
|
53
|
+
Start-Process (Join-Path $out "index.html")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Use the actual project database path; `.data/app.db` is only an example. Do not point the learning tool at Production data.
|
|
57
|
+
|
|
58
|
+
### macOS/Linux example
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
out="${TMPDIR:-/tmp}/lean-db-lab"
|
|
62
|
+
python3 tools/lean-db-lab/sqlite-workbench.py export \
|
|
63
|
+
--db .data/app.db \
|
|
64
|
+
--out "$out"
|
|
65
|
+
open "$out/index.html" # macOS; use the local browser command appropriate to the environment
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Add query-to-ERD evidence
|
|
69
|
+
|
|
70
|
+
Create a disposable query-evidence JSON file from captured or otherwise verified SQL:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
[
|
|
74
|
+
{
|
|
75
|
+
"name": "Get weekly meal plan",
|
|
76
|
+
"sql": "SELECT r.Id, r.Name FROM MealPlanItems mpi JOIN Recipes r ON r.Id = mpi.RecipeId WHERE mpi.MealPlanId = :mealPlanId",
|
|
77
|
+
"parameters": {
|
|
78
|
+
"mealPlanId": 42
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Then regenerate the workbench:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
$out = Join-Path $env:TEMP "lean-db-lab"
|
|
88
|
+
python .\tools\lean-db-lab\sqlite-workbench.py export `
|
|
89
|
+
--db .\.data\app.db `
|
|
90
|
+
--queries .\tmp\db-lab-queries.json `
|
|
91
|
+
--out $out
|
|
92
|
+
Start-Process (Join-Path $out "index.html")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The query-evidence file and generated workbench are learning artifacts. Keep them disposable/local unless the project explicitly chooses to make a sanitized artifact durable.
|
|
96
|
+
|
|
97
|
+
### What the V1 viewer shows
|
|
98
|
+
|
|
99
|
+
The SQLite V1 workbench supports:
|
|
100
|
+
|
|
101
|
+
- tables and views;
|
|
102
|
+
- columns, types, nullability, and primary-key participation;
|
|
103
|
+
- foreign-key relationships and delete/update actions;
|
|
104
|
+
- indexes, uniqueness, origin, partial-index status, key columns, and stored DDL when available;
|
|
105
|
+
- junction-table candidates, clearly labeled as a heuristic rather than domain truth;
|
|
106
|
+
- clickable tables, columns, and indexes with a learning/details panel;
|
|
107
|
+
- query selection and highlighting of referenced tables;
|
|
108
|
+
- highlighting of relationship edges when both related tables participate in the selected query;
|
|
109
|
+
- highlighting of qualified query columns when resolvable;
|
|
110
|
+
- `EXPLAIN QUERY PLAN` evidence for parameterized `SELECT`/`WITH` queries;
|
|
111
|
+
- a distinction between indexes selected by the planner and indexes that are merely plausible candidates/relevant to highlighted columns.
|
|
112
|
+
|
|
113
|
+
The viewer does not claim to understand arbitrary SQL perfectly. SQL-to-table/column mapping includes heuristic parsing, while planner-selected indexes come from SQLite's own query-plan evidence.
|
|
114
|
+
|
|
115
|
+
## What to expect from `/db-lab`
|
|
116
|
+
|
|
117
|
+
A useful Database Lab session follows evidence rather than guesses:
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
repository intent
|
|
121
|
+
→ ORM model
|
|
122
|
+
→ physical schema
|
|
123
|
+
→ query / executed SQL
|
|
124
|
+
→ query plan
|
|
125
|
+
→ indexes / constraints / transaction behavior
|
|
126
|
+
→ explanation or exercise
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The exact evidence depends on the stack. The lab should explicitly state which layers were verified and which were inferred.
|
|
130
|
+
|
|
131
|
+
## Example 1 — explore the schema
|
|
132
|
+
|
|
133
|
+
Prompt:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
/db-lab schema
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Expected learning flow:
|
|
140
|
+
|
|
141
|
+
1. Identify the configured development/test database and relevant ORM/migration artifacts.
|
|
142
|
+
2. Build the table/entity/relationship picture from safe evidence.
|
|
143
|
+
3. Show primary keys, foreign keys, nullability, constraints, and indexes.
|
|
144
|
+
4. Explain important relationship cardinalities.
|
|
145
|
+
5. Compare Domain Model, ORM Model, and Physical Model where they differ.
|
|
146
|
+
6. Ask one or two high-value questions, such as why a junction table exists or what invariant belongs in the database.
|
|
147
|
+
|
|
148
|
+
With SQLite, use the distributed workbench when a safe local database is available. Selecting an index should explain its columns, uniqueness, how SQLite created it, and whether the active query plan actually selected it.
|
|
149
|
+
|
|
150
|
+
## Example 2 — Entity Framework to raw SQL
|
|
151
|
+
|
|
152
|
+
Suppose application code contains:
|
|
153
|
+
|
|
154
|
+
```csharp
|
|
155
|
+
var recipes = await db.Recipes
|
|
156
|
+
.Include(r => r.Ingredients)
|
|
157
|
+
.Where(r => r.IsFavorite)
|
|
158
|
+
.OrderBy(r => r.Name)
|
|
159
|
+
.ToListAsync();
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Prompt:
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
/db-lab trace this EF query
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The lab should connect:
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
LINQ / EF expression
|
|
172
|
+
→ translation preview when available
|
|
173
|
+
→ captured executed SQL when available
|
|
174
|
+
→ parameters
|
|
175
|
+
→ tables and relationships
|
|
176
|
+
→ provider query plan
|
|
177
|
+
→ indexes selected by the planner
|
|
178
|
+
→ result materialization
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Important teaching point: a translation preview and an actually executed command are different kinds of evidence. Label them separately.
|
|
182
|
+
|
|
183
|
+
For EF Core, `ToQueryString()` can help inspect translation. Framework-supported command logging/interception can provide evidence of the actual `DbCommand`. The SQLite workbench consumes captured SQL; it does not replace EF command capture.
|
|
184
|
+
|
|
185
|
+
## Example 3 — query-to-ERD highlighting
|
|
186
|
+
|
|
187
|
+
Prompt:
|
|
188
|
+
|
|
189
|
+
```text
|
|
190
|
+
/db-lab trace GetWeeklyMealPlan and show it on the ERD
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
For a query that touches `MealPlans`, `MealPlanItems`, and `Recipes`, the workbench highlights those tables. If both ends of an FK relationship participate, the corresponding relationship edge is emphasized. Qualified columns found in the query are highlighted in their table cards.
|
|
194
|
+
|
|
195
|
+
If `EXPLAIN QUERY PLAN` shows an index was actually used, the viewer marks it as **planner selected**. If an index's leading column matches highlighted query columns but the planner did not select it, the viewer can mark it as a **candidate/relevant** index without claiming usage.
|
|
196
|
+
|
|
197
|
+
Selecting a table, column, or index opens a learning/details panel. The query panel shows the captured SQL and SQLite plan details alongside the ERD.
|
|
198
|
+
|
|
199
|
+
If the interactive viewer is unavailable, use a temporary Mermaid/text diagram and explain that the rich query-to-ERD interaction is unavailable in the current checkout.
|
|
200
|
+
|
|
201
|
+
## Example 4 — query-plan debugging
|
|
202
|
+
|
|
203
|
+
Prompt:
|
|
204
|
+
|
|
205
|
+
```text
|
|
206
|
+
/db-lab why is this query slow?
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Preferred learning sequence:
|
|
210
|
+
|
|
211
|
+
```text
|
|
212
|
+
show query/access pattern
|
|
213
|
+
→ developer predicts plan/index behavior
|
|
214
|
+
→ inspect provider-native plan
|
|
215
|
+
→ identify scan/search/join evidence
|
|
216
|
+
→ developer proposes a change
|
|
217
|
+
→ predict the changed plan
|
|
218
|
+
→ compare safely when a sandbox is available
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
For SQLite, the V1 workbench uses `EXPLAIN QUERY PLAN` for `SELECT`/`WITH` queries when supplied parameters are sufficient. A learning session should connect `SCAN`/`SEARCH` behavior to concrete predicates, joins, ordering, and available indexes rather than simply recommending more indexes.
|
|
222
|
+
|
|
223
|
+
## Example 5 — migration review
|
|
224
|
+
|
|
225
|
+
Prompt:
|
|
226
|
+
|
|
227
|
+
```text
|
|
228
|
+
/db-lab migration AddRecipeRatings
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The lab should show, when available:
|
|
232
|
+
|
|
233
|
+
```text
|
|
234
|
+
migration intent
|
|
235
|
+
↔ migration/ORM operations
|
|
236
|
+
↔ generated SQL/DDL
|
|
237
|
+
↔ schema before
|
|
238
|
+
↔ schema after
|
|
239
|
+
↔ data-safety concerns
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Useful questions include:
|
|
243
|
+
|
|
244
|
+
- Is existing data compatible with a new non-null column?
|
|
245
|
+
- Is a backfill required?
|
|
246
|
+
- Does a new uniqueness constraint match the domain invariant?
|
|
247
|
+
- Is a table rebuild or destructive operation involved?
|
|
248
|
+
- What rollback limitations exist?
|
|
249
|
+
|
|
250
|
+
Do not apply the migration in Database Lab mode.
|
|
251
|
+
|
|
252
|
+
## Example 6 — database-design interview
|
|
253
|
+
|
|
254
|
+
Prompt:
|
|
255
|
+
|
|
256
|
+
```text
|
|
257
|
+
/db-lab interview database
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
The interviewer should use the project domain for familiarity but change requirements so memorizing the existing schema does not solve the exercise.
|
|
261
|
+
|
|
262
|
+
Example follow-ups:
|
|
263
|
+
|
|
264
|
+
```text
|
|
265
|
+
Why does this many-to-many relationship need an associative table?
|
|
266
|
+
Could the two foreign keys be the primary key? What requirement would break that design?
|
|
267
|
+
Which invariants belong in database constraints rather than application validation?
|
|
268
|
+
What queries justify this index?
|
|
269
|
+
What happens to historical records if the parent entity is deleted?
|
|
270
|
+
How would this design change if multiple users edit the same aggregate concurrently?
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Use the standard L1-L6 learning levels, but assess database competencies independently. SQL syntax skill must not hide weak schema-design or indexing reasoning.
|
|
274
|
+
|
|
275
|
+
## Database competency model
|
|
276
|
+
|
|
277
|
+
```text
|
|
278
|
+
Relational modeling entities, relationships, cardinality
|
|
279
|
+
Keys + integrity PK/FK/unique/check/nullability choices
|
|
280
|
+
Normalization anomalies and deliberate denormalization
|
|
281
|
+
SQL query construction joins, aggregation, subqueries/CTEs, pagination
|
|
282
|
+
Indexes + access patterns index choices tied to real reads/writes
|
|
283
|
+
Query plans evidence-based performance reasoning
|
|
284
|
+
Transactions + concurrency atomicity, isolation, conflict/failure behavior
|
|
285
|
+
ORM translation what the abstraction generates/hides
|
|
286
|
+
Schema evolution migrations, compatibility, data safety
|
|
287
|
+
Debugging symptom → evidence → cause
|
|
288
|
+
Design defense tradeoffs and interview follow-up
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
A developer can be at different levels in each competency. Do not report one undifferentiated "SQL score".
|
|
292
|
+
|
|
293
|
+
## Provider / ORM architecture
|
|
294
|
+
|
|
295
|
+
The workbench stays provider/ORM-adapter oriented rather than becoming Family Meal Planner-specific.
|
|
296
|
+
|
|
297
|
+
```text
|
|
298
|
+
Database adapter
|
|
299
|
+
SQLite V1
|
|
300
|
+
PostgreSQL / SQL Server / ... future
|
|
301
|
+
|
|
302
|
+
ORM evidence
|
|
303
|
+
EF Core first concrete path
|
|
304
|
+
Hibernate / SQLAlchemy / ... future
|
|
305
|
+
|
|
306
|
+
Canonical learning model
|
|
307
|
+
tables
|
|
308
|
+
columns
|
|
309
|
+
constraints
|
|
310
|
+
relationships
|
|
311
|
+
indexes
|
|
312
|
+
queries
|
|
313
|
+
query-plan steps
|
|
314
|
+
migrations
|
|
315
|
+
|
|
316
|
+
Interactive viewer
|
|
317
|
+
schema navigation
|
|
318
|
+
learning panels
|
|
319
|
+
query-to-ERD highlighting
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
SQLite + EF Core is the first concrete learning path, not a permanent architectural restriction.
|
|
323
|
+
|
|
324
|
+
## IDE tooling
|
|
325
|
+
|
|
326
|
+
Database extensions can improve the human exploration loop, but `/db-lab` must not depend on manipulating their UI.
|
|
327
|
+
|
|
328
|
+
For SQLite projects, Bootstrap may recommend SQLTools plus its SQLite driver so the developer can independently browse/query the same local database. The reusable skill and workbench still obtain their authoritative evidence from repository/framework/provider-supported mechanisms.
|
|
329
|
+
|
|
330
|
+
## Safety and fallbacks
|
|
331
|
+
|
|
332
|
+
Database Lab is read-only learning by default.
|
|
333
|
+
|
|
334
|
+
Do not:
|
|
335
|
+
|
|
336
|
+
- connect to Production for learning exercises;
|
|
337
|
+
- mutate real application data;
|
|
338
|
+
- apply/revert migrations;
|
|
339
|
+
- create/drop indexes;
|
|
340
|
+
- change code to prove a point;
|
|
341
|
+
- claim an index was used without plan evidence;
|
|
342
|
+
- manufacture executed SQL when only ORM source is available.
|
|
343
|
+
|
|
344
|
+
The SQLite V1 workbench opens the database with SQLite `mode=ro`. Generated HTML/JSON are disposable learning artifacts and should normally go to a temp directory rather than tracked project paths.
|
|
345
|
+
|
|
346
|
+
If evidence is missing, say so and continue with the strongest safe layer available. A missing database runtime, ORM trace, or interactive viewer should degrade the experience; it should not block learning or engineering delivery.
|