@mriekki/lean 0.4.3 → 0.4.5

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.
Files changed (35) hide show
  1. package/assets/components.json +3 -3
  2. package/assets/core/distribution.json +8 -0
  3. package/assets/deployment/distribution.json +2 -0
  4. package/assets/generated/ASSEMBLY.json +73 -23
  5. package/assets/generated/core/core/instructions/lean-docs.instructions.md +33 -2
  6. package/assets/generated/core/core/instructions/lean-workflow.instructions.md +42 -0
  7. package/assets/generated/core/core/learning/DIAGRAM_GUIDE.md +46 -6
  8. package/assets/generated/core/core/learning/ENGINEERING_LEARNING_WORKBOOK.md +29 -6
  9. package/assets/generated/core/core/learning/LEARNING_MAP.md +37 -2
  10. package/assets/generated/core/core/learning/LEARNING_PROGRESS.md +15 -7
  11. package/assets/generated/core/core/learning/SYSTEM_DESIGN_DRILLS.md +299 -19
  12. package/assets/generated/core/core/process/COACHING_GUIDE.md +35 -2
  13. package/assets/generated/core/core/process/DATABASE_LEARNING_WORKBENCH.md +153 -102
  14. package/assets/generated/core/core/process/DEPLOYMENT_ENABLEMENT.md +108 -71
  15. package/assets/generated/core/core/process/LEAN_ENGINEERING_GUIDE.md +317 -0
  16. package/assets/generated/core/core/process/PROJECT_DOCUMENTATION_FRAMEWORK.md +324 -0
  17. package/assets/generated/core/core/process/SYSTEM_DESIGN_LEARNING_WORKBENCH.md +520 -0
  18. package/assets/generated/core/core/skills/coach/SKILL.md +31 -4
  19. package/assets/generated/core/core/skills/db-lab/SKILL.md +59 -16
  20. package/assets/generated/core/core/skills/deliver/SKILL.md +77 -5
  21. package/assets/generated/core/core/skills/deploy/SKILL.md +164 -121
  22. package/assets/generated/core/core/skills/deployment-readiness/SKILL.md +223 -250
  23. package/assets/generated/core/core/skills/docs/SKILL.md +116 -0
  24. package/assets/generated/core/core/skills/next-step/SKILL.md +21 -6
  25. package/assets/generated/core/core/skills/system-lab/SKILL.md +333 -0
  26. package/assets/generated/core/core/skills/tear-down/SKILL.md +101 -61
  27. package/assets/generated/core/core/templates/ADR_TEMPLATE.md +41 -0
  28. package/assets/generated/core/tools/docs_site/docs_site.py +382 -0
  29. package/assets/generated/core/tools/system_lab/system_workbench.py +243 -0
  30. package/assets/generated/deployment/src/lean_poc_deployment/entrypoint.py +5 -1
  31. package/assets/generated/deployment/src/lean_poc_deployment/local_cli.py +112 -0
  32. package/assets/generated/deployment/src/lean_poc_deployment/local_runtime.py +523 -0
  33. package/assets/generated/deployment/src/lean_poc_deployment/teardown.py +49 -35
  34. package/assets/generated/deployment/src/lean_poc_deployment/teardown_cli.py +31 -12
  35. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
 
3
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
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.
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
6
 
7
7
  Learning remains optional and never changes engineering delivery state.
8
8
 
@@ -12,7 +12,9 @@ Use `/coach` for explanation, adaptive questioning, and gap assessment. Use `/db
12
12
 
13
13
  ```text
14
14
  /coach database design
15
+ /db-lab
15
16
  /db-lab schema
17
+ /db-lab changes <work-item>
16
18
  /db-lab trace <query/file/symbol>
17
19
  /db-lab plan <query>
18
20
  /db-lab debug <symptom/query>
@@ -20,10 +22,13 @@ Use `/coach` for explanation, adaptive questioning, and gap assessment. Use `/db
20
22
  /db-lab interview database
21
23
  ```
22
24
 
25
+ Invoking `/db-lab` means **inspect current evidence and show the current view**. The learner should not need to remember to refresh, rebuild, or manually maintain an ER diagram.
26
+
23
27
  Natural-language arguments are preferred over rigid syntax. Examples:
24
28
 
25
29
  ```text
26
30
  /db-lab show me how Recipes and Ingredients are related
31
+ /db-lab changes WI-24
27
32
  /db-lab trace the EF query used by GetWeeklyMealPlan
28
33
  /db-lab why is this query scanning MealPlanItems
29
34
  /db-lab show which indexes this query actually uses
@@ -31,7 +36,22 @@ Natural-language arguments are preferred over rigid syntax. Examples:
31
36
  /db-lab give me a database-design interview based on this domain
32
37
  ```
33
38
 
34
- ## SQLite interactive workbench — V1
39
+ ## Current-by-default artifact lifecycle
40
+
41
+ Generated workbench HTML/JSON is a disposable projection:
42
+
43
+ ```text
44
+ current safe database/repository evidence
45
+ → inspect schema / ORM / migrations / queries
46
+ → build current learning model
47
+ → generate current interactive view
48
+ ```
49
+
50
+ The database/repository evidence remains authoritative. An older browser tab is not authoritative. Run the lab again and it produces the current view.
51
+
52
+ When a previous disposable snapshot is available it may help explain what changed, but never outranks current physical/ORM/migration evidence.
53
+
54
+ ## SQLite interactive workbench
35
55
 
36
56
  Greenfield consumers that include the Core learning payload receive:
37
57
 
@@ -39,13 +59,14 @@ Greenfield consumers that include the Core learning payload receive:
39
59
  tools/lean-db-lab/sqlite-workbench.py
40
60
  ```
41
61
 
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`.
62
+ The tool is dependency-free Python and opens SQLite databases read-only. It generates a self-contained interactive `index.html` and machine-readable `workbench.json`.
43
63
 
44
- ### PowerShell example
64
+ ### PowerShell
45
65
 
46
- From the repository root, using a known development/test SQLite file:
66
+ From the repository root, using a **known safe development/test** SQLite file:
47
67
 
48
68
  ```powershell
69
+ Set-Location D:\Projects\<repo>
49
70
  $out = Join-Path $env:TEMP "lean-db-lab"
50
71
  python .\tools\lean-db-lab\sqlite-workbench.py export `
51
72
  --db .\.data\app.db `
@@ -53,19 +74,20 @@ python .\tools\lean-db-lab\sqlite-workbench.py export `
53
74
  Start-Process (Join-Path $out "index.html")
54
75
  ```
55
76
 
56
- Use the actual project database path; `.data/app.db` is only an example. Do not point the learning tool at Production data.
77
+ `.data/app.db` is only an example. Use the actual project development/test database path. Never point the learning tool at Production.
57
78
 
58
- ### macOS/Linux example
79
+ ### macOS/Linux
59
80
 
60
81
  ```bash
82
+ cd /path/to/repo
61
83
  out="${TMPDIR:-/tmp}/lean-db-lab"
62
84
  python3 tools/lean-db-lab/sqlite-workbench.py export \
63
85
  --db .data/app.db \
64
86
  --out "$out"
65
- open "$out/index.html" # macOS; use the local browser command appropriate to the environment
87
+ open "$out/index.html" 2>/dev/null || xdg-open "$out/index.html"
66
88
  ```
67
89
 
68
- ### Add query-to-ERD evidence
90
+ ### Query-to-ERD evidence
69
91
 
70
92
  Create a disposable query-evidence JSON file from captured or otherwise verified SQL:
71
93
 
@@ -81,7 +103,7 @@ Create a disposable query-evidence JSON file from captured or otherwise verified
81
103
  ]
82
104
  ```
83
105
 
84
- Then regenerate the workbench:
106
+ Run the workbench with that evidence:
85
107
 
86
108
  ```powershell
87
109
  $out = Join-Path $env:TEMP "lean-db-lab"
@@ -92,11 +114,11 @@ python .\tools\lean-db-lab\sqlite-workbench.py export `
92
114
  Start-Process (Join-Path $out "index.html")
93
115
  ```
94
116
 
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.
117
+ Each invocation produces the current view. The query-evidence file and generated workbench stay disposable/local unless the project explicitly chooses a sanitized durable artifact.
96
118
 
97
- ### What the V1 viewer shows
119
+ ## What the interactive viewer shows
98
120
 
99
- The SQLite V1 workbench supports:
121
+ The SQLite workbench supports:
100
122
 
101
123
  - tables and views;
102
124
  - columns, types, nullability, and primary-key participation;
@@ -105,8 +127,8 @@ The SQLite V1 workbench supports:
105
127
  - junction-table candidates, clearly labeled as a heuristic rather than domain truth;
106
128
  - clickable tables, columns, and indexes with a learning/details panel;
107
129
  - 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;
130
+ - relationship-edge highlighting when both related tables participate;
131
+ - qualified query-column highlighting when resolvable;
110
132
  - `EXPLAIN QUERY PLAN` evidence for parameterized `SELECT`/`WITH` queries;
111
133
  - a distinction between indexes selected by the planner and indexes that are merely plausible candidates/relevant to highlighted columns.
112
134
 
@@ -114,7 +136,7 @@ The viewer does not claim to understand arbitrary SQL perfectly. SQL-to-table/co
114
136
 
115
137
  ## What to expect from `/db-lab`
116
138
 
117
- A useful Database Lab session follows evidence rather than guesses:
139
+ A useful session follows evidence rather than guesses:
118
140
 
119
141
  ```text
120
142
  repository intent
@@ -126,85 +148,75 @@ repository intent
126
148
  → explanation or exercise
127
149
  ```
128
150
 
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
151
+ Explicitly state which layers were verified and which were inferred.
132
152
 
133
- Prompt:
153
+ Where useful, distinguish:
134
154
 
135
155
  ```text
136
- /db-lab schema
156
+ DOMAIN MODEL
157
+ ORM MODEL
158
+ PHYSICAL MODEL
137
159
  ```
138
160
 
139
- Expected learning flow:
161
+ ## Change-focused learning
140
162
 
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.
163
+ Prompt:
147
164
 
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.
165
+ ```text
166
+ /db-lab changes WI-24
167
+ ```
149
168
 
150
- ## Example 2 — Entity Framework to raw SQL
169
+ Use the accepted/delivered change set plus current database evidence. Explain relevant changes to:
151
170
 
152
- Suppose application code contains:
171
+ - entities/tables and columns;
172
+ - primary/foreign/unique/check constraints;
173
+ - nullability and cascade behavior;
174
+ - indexes and access paths;
175
+ - ORM mappings and translation behavior;
176
+ - migrations/DDL and data-safety implications;
177
+ - query paths;
178
+ - transactions/concurrency.
153
179
 
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
- ```
180
+ A changed entity/migration/query file proves that database-related code was touched. It does **not** by itself prove that the physical database changed. Verify the physical layer when safe evidence is available.
161
181
 
162
- Prompt:
182
+ A good learning summary connects the change to its consequence:
163
183
 
164
184
  ```text
165
- /db-lab trace this EF query
185
+ added relationship
186
+ → new FK/invariant
187
+ → new join/access path
188
+ → possible index consideration
189
+ → migration/data compatibility question
166
190
  ```
167
191
 
168
- The lab should connect:
192
+ ## Entity Framework to raw SQL
193
+
194
+ For EF Core, connect:
169
195
 
170
196
  ```text
171
197
  LINQ / EF expression
172
- → translation preview when available
173
- → captured executed SQL when available
198
+ → translation preview such as ToQueryString() when appropriate
199
+ → captured actual DbCommand when available
174
200
  → parameters
175
201
  → tables and relationships
176
202
  → provider query plan
177
203
  → 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
204
+ → result materialization/tracking
191
205
  ```
192
206
 
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.
207
+ Translation preview and an actually executed command are different evidence. Label them separately. Use supported logging/interception for executed-command evidence; the SQLite workbench consumes captured SQL and does not replace EF command capture.
194
208
 
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.
209
+ Apply the same principle to other ORMs using framework-supported mechanisms.
196
210
 
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.
211
+ ## Query-to-ERD highlighting
198
212
 
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.
213
+ For a query touching `MealPlans`, `MealPlanItems`, and `Recipes`, highlight those tables. If both ends of an FK relationship participate, emphasize the edge. Highlight resolvable qualified columns.
200
214
 
201
- ## Example 4 — query-plan debugging
215
+ If `EXPLAIN QUERY PLAN` says an index was used, mark it **planner selected**. An index whose leading column appears relevant but was not selected can be shown as **candidate/relevant**, never as used.
202
216
 
203
- Prompt:
217
+ If the interactive viewer is unavailable, use a temporary Mermaid/text diagram and clearly label the fallback.
204
218
 
205
- ```text
206
- /db-lab why is this query slow?
207
- ```
219
+ ## Query-plan debugging
208
220
 
209
221
  Preferred learning sequence:
210
222
 
@@ -214,13 +226,13 @@ show query/access pattern
214
226
  → inspect provider-native plan
215
227
  → identify scan/search/join evidence
216
228
  → developer proposes a change
217
- → predict the changed plan
229
+ → predict changed plan
218
230
  → compare safely when a sandbox is available
219
231
  ```
220
232
 
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.
233
+ Do not teach "add an index" without connecting it to a concrete access pattern, selectivity/order needs, write cost and plan evidence.
222
234
 
223
- ## Example 5 — migration review
235
+ ## Migration review
224
236
 
225
237
  Prompt:
226
238
 
@@ -228,28 +240,28 @@ Prompt:
228
240
  /db-lab migration AddRecipeRatings
229
241
  ```
230
242
 
231
- The lab should show, when available:
243
+ Connect:
232
244
 
233
245
  ```text
234
246
  migration intent
235
247
  ↔ migration/ORM operations
236
- ↔ generated SQL/DDL
248
+ ↔ generated SQL/DDL when available
237
249
  ↔ schema before
238
250
  ↔ schema after
239
251
  ↔ data-safety concerns
240
252
  ```
241
253
 
242
- Useful questions include:
254
+ Useful questions:
243
255
 
244
256
  - Is existing data compatible with a new non-null column?
245
257
  - Is a backfill required?
246
- - Does a new uniqueness constraint match the domain invariant?
247
- - Is a table rebuild or destructive operation involved?
258
+ - Does a uniqueness constraint match the invariant?
259
+ - Is a table rebuild/destructive operation involved?
248
260
  - What rollback limitations exist?
249
261
 
250
262
  Do not apply the migration in Database Lab mode.
251
263
 
252
- ## Example 6 — database-design interview
264
+ ## Database-design interview
253
265
 
254
266
  Prompt:
255
267
 
@@ -257,46 +269,85 @@ Prompt:
257
269
  /db-lab interview database
258
270
  ```
259
271
 
260
- The interviewer should use the project domain for familiarity but change requirements so memorizing the existing schema does not solve the exercise.
272
+ Use the project domain for familiarity but perturb requirements so memorizing the schema does not solve the exercise.
261
273
 
262
- Example follow-ups:
274
+ Drive:
263
275
 
264
276
  ```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?
277
+ requirements
278
+ → entities
279
+ → relationships/cardinality
280
+ → keys/constraints
281
+ → normalization
282
+ → access patterns
283
+ → indexes/plans
284
+ → transactions/concurrency
285
+ → evolution/scaling
286
+ → design defense
271
287
  ```
272
288
 
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.
289
+ Ask why a junction table exists, why a key was chosen, what deletion means historically, which query justifies an index, which invariant belongs in a database constraint, and what changes under concurrent edits.
274
290
 
275
291
  ## Database competency model
276
292
 
277
293
  ```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
294
+ relational modeling
295
+ keys + integrity constraints
296
+ normalization + data anomalies
297
+ SQL query construction
298
+ indexes + access patterns
299
+ query plans + performance reasoning
300
+ transactions + concurrency
301
+ ORM translation + abstraction leaks
302
+ schema evolution + migrations
303
+ database debugging
304
+ design defense + interview communication
289
305
  ```
290
306
 
291
- A developer can be at different levels in each competency. Do not report one undifferentiated "SQL score".
307
+ Use L1-L6 per competency rather than one undifferentiated SQL score.
308
+
309
+ ## Cross-lab learning
310
+
311
+ System Lab owns system context; Database Lab owns database depth.
312
+
313
+ ```text
314
+ /system-lab runtime checkout
315
+ → identify Orders DB
316
+ → /db-lab trace <order query>
317
+
318
+ /db-lab plan <query>
319
+ → database evidence looks healthy but end-to-end latency is high
320
+ → /system-lab performance checkout
321
+ ```
322
+
323
+ ## Delivery-completion visibility
324
+
325
+ Successful delivery may visibly recommend:
326
+
327
+ ```text
328
+ ★ /db-lab changes WI-24
329
+ This work changed database structure or behavior.
330
+ Explore affected relationships, queries, indexes, constraints, and ORM behavior.
331
+ ```
332
+
333
+ When database-specific evidence was not materially touched, `/db-lab` may still appear as an available option:
334
+
335
+ ```text
336
+ ○ /db-lab
337
+ Explore the current database schema, relationships, queries, indexes, and ORM behavior.
338
+ ```
339
+
340
+ Do not tell the learner to rebuild or refresh a diagram. Current evidence is part of invoking the lab.
341
+
342
+ After successful merge/default-branch CI, `/deliver` may prepare a disposable SQLite workbench automatically only when the accepted change is DB-relevant, the tool exists, and a safe local development/test SQLite database path is already known. Never guess the path, create/apply migrations, mutate data, or touch Production just to prepare learning output. Failure remains non-blocking.
292
343
 
293
344
  ## Provider / ORM architecture
294
345
 
295
- The workbench stays provider/ORM-adapter oriented rather than becoming Family Meal Planner-specific.
346
+ The workbench stays provider/ORM-adapter oriented rather than application-specific.
296
347
 
297
348
  ```text
298
349
  Database adapter
299
- SQLite V1
350
+ SQLite concrete path
300
351
  PostgreSQL / SQL Server / ... future
301
352
 
302
353
  ORM evidence
@@ -319,13 +370,13 @@ Interactive viewer
319
370
  query-to-ERD highlighting
320
371
  ```
321
372
 
322
- SQLite + EF Core is the first concrete learning path, not a permanent architectural restriction.
373
+ SQLite + EF Core is a first concrete learning path, not a permanent architectural restriction.
323
374
 
324
375
  ## IDE tooling
325
376
 
326
377
  Database extensions can improve the human exploration loop, but `/db-lab` must not depend on manipulating their UI.
327
378
 
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.
379
+ For SQLite projects, Bootstrap may recommend SQLTools plus its SQLite driver so the developer can independently browse/query the same local database. The reusable lab obtains authoritative evidence from repository/framework/provider-supported mechanisms.
329
380
 
330
381
  ## Safety and fallbacks
331
382
 
@@ -334,13 +385,13 @@ Database Lab is read-only learning by default.
334
385
  Do not:
335
386
 
336
387
  - connect to Production for learning exercises;
337
- - mutate real application data;
388
+ - mutate application data;
338
389
  - apply/revert migrations;
339
390
  - create/drop indexes;
340
391
  - change code to prove a point;
341
392
  - claim an index was used without plan evidence;
342
393
  - manufacture executed SQL when only ORM source is available.
343
394
 
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.
395
+ The SQLite workbench opens the database with SQLite `mode=ro`. Generated HTML/JSON are disposable learning artifacts and should normally go to temp/cache rather than tracked project paths.
345
396
 
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.
397
+ If evidence is missing, say so and continue with the strongest safe layer available. A missing database runtime, ORM trace, interactive viewer, or post-delivery artifact should degrade the experience; it should never block learning or engineering delivery.