@atlashub/smartstack-cli 3.36.0 → 3.38.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.
Files changed (219) hide show
  1. package/dist/index.js +16 -24
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +201 -256
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +3 -2
  6. package/scripts/extract-api-endpoints.ts +325 -0
  7. package/scripts/extract-business-rules.ts +440 -0
  8. package/scripts/generate-doc-with-mock-ui.ts +804 -0
  9. package/scripts/health-check.sh +168 -0
  10. package/scripts/postinstall.js +18 -0
  11. package/templates/agents/ba-reader.md +9 -9
  12. package/templates/agents/ba-writer.md +12 -15
  13. package/templates/agents/code-reviewer.md +1 -1
  14. package/templates/agents/docs-context-reader.md +1 -1
  15. package/templates/agents/gitflow/merge.md +0 -4
  16. package/templates/agents/gitflow/pr.md +0 -4
  17. package/templates/agents/gitflow/start.md +30 -5
  18. package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +20 -20
  19. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +16 -24
  20. package/templates/mcp-scaffolding/migrations/seed-roles.cs.hbs +2 -2
  21. package/templates/skills/_resources/mcp-validate-documentation-spec.md +3 -3
  22. package/templates/skills/_shared.md +15 -17
  23. package/templates/skills/ai-prompt/SKILL.md +1 -1
  24. package/templates/skills/ai-prompt/steps/step-00-init.md +47 -0
  25. package/templates/skills/apex/SKILL.md +3 -4
  26. package/templates/skills/apex/_shared.md +10 -20
  27. package/templates/skills/apex/references/analysis-methods.md +141 -0
  28. package/templates/skills/apex/references/challenge-questions.md +1 -21
  29. package/templates/skills/apex/references/core-seed-data.md +35 -57
  30. package/templates/skills/apex/references/examine-build-validation.md +87 -0
  31. package/templates/skills/apex/references/execution-frontend-gates.md +177 -0
  32. package/templates/skills/apex/references/execution-frontend-patterns.md +105 -0
  33. package/templates/skills/apex/references/execution-layer1-rules.md +96 -0
  34. package/templates/skills/apex/references/initialization-challenge-flow.md +110 -0
  35. package/templates/skills/apex/references/planning-layer-mapping.md +151 -0
  36. package/templates/skills/apex/references/post-checks.md +145 -40
  37. package/templates/skills/apex/references/smartstack-api.md +35 -51
  38. package/templates/skills/apex/references/smartstack-frontend.md +17 -17
  39. package/templates/skills/apex/references/smartstack-layers.md +38 -62
  40. package/templates/skills/apex/steps/step-00-init.md +14 -26
  41. package/templates/skills/apex/steps/step-01-analyze.md +10 -143
  42. package/templates/skills/apex/steps/step-02-plan.md +10 -92
  43. package/templates/skills/apex/steps/step-03-execute.md +47 -249
  44. package/templates/skills/apex/steps/step-04-examine.md +14 -78
  45. package/templates/skills/apex/steps/step-05-deep-review.md +2 -2
  46. package/templates/skills/apex/steps/step-08-run-tests.md +2 -0
  47. package/templates/skills/application/SKILL.md +6 -7
  48. package/templates/skills/application/references/backend-controller-hierarchy.md +16 -16
  49. package/templates/skills/application/references/backend-seeding-and-dto-output.md +83 -0
  50. package/templates/skills/application/references/backend-table-prefix-mapping.md +79 -0
  51. package/templates/skills/application/references/backend-verification.md +1 -1
  52. package/templates/skills/application/references/frontend-i18n-and-output.md +67 -0
  53. package/templates/skills/application/references/frontend-route-naming.md +117 -0
  54. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +107 -0
  55. package/templates/skills/application/references/frontend-verification.md +12 -12
  56. package/templates/skills/application/references/init-parameter-detection.md +120 -0
  57. package/templates/skills/application/references/migration-checklist-troubleshooting.md +100 -0
  58. package/templates/skills/application/references/nav-fallback-procedure.md +5 -6
  59. package/templates/skills/application/references/provider-template.md +2 -6
  60. package/templates/skills/application/references/roles-client-project-handling.md +55 -0
  61. package/templates/skills/application/references/roles-fallback-procedure.md +149 -0
  62. package/templates/skills/application/references/test-coverage-requirements.md +213 -0
  63. package/templates/skills/application/references/test-frontend.md +3 -3
  64. package/templates/skills/application/steps/step-00-init.md +11 -141
  65. package/templates/skills/application/steps/step-01-navigation.md +3 -3
  66. package/templates/skills/application/steps/step-02-permissions.md +4 -4
  67. package/templates/skills/application/steps/step-03-roles.md +18 -175
  68. package/templates/skills/application/steps/step-03b-provider.md +1 -2
  69. package/templates/skills/application/steps/step-04-backend.md +19 -110
  70. package/templates/skills/application/steps/step-05-frontend.md +17 -143
  71. package/templates/skills/application/steps/step-06-migration.md +12 -60
  72. package/templates/skills/application/steps/step-07-tests.md +9 -76
  73. package/templates/skills/application/templates-backend.md +29 -27
  74. package/templates/skills/application/templates-frontend.md +48 -48
  75. package/templates/skills/application/templates-seed.md +57 -131
  76. package/templates/skills/business-analyse/SKILL.md +27 -30
  77. package/templates/skills/business-analyse/_architecture.md +6 -6
  78. package/templates/skills/business-analyse/_shared.md +60 -88
  79. package/templates/skills/business-analyse/questionnaire/04-data.md +3 -3
  80. package/templates/skills/business-analyse/questionnaire/06-security.md +1 -1
  81. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +1 -1
  82. package/templates/skills/business-analyse/react/application-viewer.md +12 -12
  83. package/templates/skills/business-analyse/react/components.md +8 -12
  84. package/templates/skills/business-analyse/react/schema.md +11 -11
  85. package/templates/skills/business-analyse/references/agent-module-prompt.md +2 -3
  86. package/templates/skills/business-analyse/references/analysis-semantic-checks.md +190 -0
  87. package/templates/skills/business-analyse/references/cache-warming-strategy.md +2 -2
  88. package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +41 -0
  89. package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +74 -0
  90. package/templates/skills/business-analyse/references/cadrage-shared-modules.md +69 -0
  91. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +1 -1
  92. package/templates/skills/business-analyse/references/compilation-structure-cards.md +297 -0
  93. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +2 -2
  94. package/templates/skills/business-analyse/references/deploy-modes.md +5 -5
  95. package/templates/skills/business-analyse/references/detection-strategies.md +7 -7
  96. package/templates/skills/business-analyse/references/handoff-file-templates.md +14 -22
  97. package/templates/skills/business-analyse/references/handoff-mappings.md +4 -4
  98. package/templates/skills/business-analyse/references/handoff-seeddata-generation.md +312 -0
  99. package/templates/skills/business-analyse/references/init-schema-deployment.md +3 -3
  100. package/templates/skills/business-analyse/references/naming-conventions.md +22 -24
  101. package/templates/skills/business-analyse/references/prd-generation.md +2 -2
  102. package/templates/skills/business-analyse/references/review-data-mapping.md +2 -2
  103. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  104. package/templates/skills/business-analyse/references/spec-auto-inference.md +3 -3
  105. package/templates/skills/business-analyse/references/team-orchestration.md +49 -6
  106. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
  107. package/templates/skills/business-analyse/references/ui-resource-cards.md +18 -18
  108. package/templates/skills/business-analyse/references/validate-incremental-html.md +2 -2
  109. package/templates/skills/business-analyse/references/validation-checklist.md +2 -2
  110. package/templates/skills/business-analyse/schemas/application-schema.json +4 -5
  111. package/templates/skills/business-analyse/schemas/project-schema.json +1 -6
  112. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +2 -3
  113. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +4 -4
  114. package/templates/skills/business-analyse/steps/step-00-init.md +8 -17
  115. package/templates/skills/business-analyse/steps/step-01-cadrage.md +35 -198
  116. package/templates/skills/business-analyse/steps/step-01b-applications.md +16 -20
  117. package/templates/skills/business-analyse/steps/step-02-decomposition.md +1 -1
  118. package/templates/skills/business-analyse/steps/step-03a1-setup.md +4 -4
  119. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +1 -1
  120. package/templates/skills/business-analyse/steps/step-03b-ui.md +4 -4
  121. package/templates/skills/business-analyse/steps/step-03c-compile.md +66 -140
  122. package/templates/skills/business-analyse/steps/step-03d-validate.md +2 -2
  123. package/templates/skills/business-analyse/steps/step-04a-collect.md +2 -2
  124. package/templates/skills/business-analyse/steps/step-04b-analyze.md +42 -160
  125. package/templates/skills/business-analyse/steps/step-04c-decide.md +1 -1
  126. package/templates/skills/business-analyse/steps/step-05a-handoff.md +74 -104
  127. package/templates/skills/business-analyse/steps/step-05b-deploy.md +13 -11
  128. package/templates/skills/business-analyse/steps/step-06-review.md +3 -3
  129. package/templates/skills/business-analyse/templates/tpl-frd.md +13 -13
  130. package/templates/skills/business-analyse/templates/tpl-handoff.md +12 -12
  131. package/templates/skills/business-analyse/templates-frd.md +25 -25
  132. package/templates/skills/business-analyse/templates-react.md +15 -21
  133. package/templates/skills/controller/SKILL.md +1 -1
  134. package/templates/skills/controller/postman-templates.md +1 -1
  135. package/templates/skills/controller/references/controller-code-templates.md +2 -2
  136. package/templates/skills/controller/references/mcp-scaffold-workflow.md +209 -0
  137. package/templates/skills/controller/references/permission-sync-templates.md +13 -16
  138. package/templates/skills/controller/steps/step-00-init.md +11 -11
  139. package/templates/skills/controller/steps/step-03-generate.md +64 -103
  140. package/templates/skills/controller/templates.md +67 -71
  141. package/templates/skills/debug/SKILL.md +13 -218
  142. package/templates/skills/debug/steps/step-00-init.md +57 -0
  143. package/templates/skills/debug/steps/step-01-analyze.md +219 -0
  144. package/templates/skills/debug/steps/step-02-resolve.md +85 -0
  145. package/templates/skills/documentation/SKILL.md +49 -345
  146. package/templates/skills/documentation/data-schema.md +11 -8
  147. package/templates/skills/documentation/steps/step-00-init.md +70 -0
  148. package/templates/skills/documentation/steps/step-01-scan.md +113 -0
  149. package/templates/skills/documentation/steps/step-02-generate.md +231 -0
  150. package/templates/skills/documentation/steps/step-03-validate.md +238 -0
  151. package/templates/skills/documentation/templates.md +480 -322
  152. package/templates/skills/efcore/references/both-contexts.md +32 -0
  153. package/templates/skills/efcore/references/database-operations.md +67 -0
  154. package/templates/skills/efcore/references/destructive-operations.md +38 -0
  155. package/templates/skills/efcore/references/reset-operations.md +81 -0
  156. package/templates/skills/efcore/references/seed-methods.md +86 -0
  157. package/templates/skills/efcore/references/shared-init-functions.md +250 -0
  158. package/templates/skills/efcore/references/sql-objects-injection.md +61 -0
  159. package/templates/skills/efcore/references/troubleshooting.md +81 -0
  160. package/templates/skills/efcore/steps/db/step-deploy.md +1 -32
  161. package/templates/skills/efcore/steps/db/step-reset.md +7 -103
  162. package/templates/skills/efcore/steps/db/step-seed.md +10 -132
  163. package/templates/skills/efcore/steps/db/step-status.md +5 -44
  164. package/templates/skills/efcore/steps/migration/step-03-validate.md +8 -62
  165. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +1 -57
  166. package/templates/skills/efcore/steps/shared/step-00-init.md +11 -254
  167. package/templates/skills/efcore/steps/squash/step-03-create.md +1 -58
  168. package/templates/skills/feature-full/SKILL.md +1 -1
  169. package/templates/skills/feature-full/steps/step-00-init.md +57 -0
  170. package/templates/skills/feature-full/steps/step-01-implementation.md +1 -1
  171. package/templates/skills/gitflow/SKILL.md +1 -1
  172. package/templates/skills/gitflow/_shared.md +23 -0
  173. package/templates/skills/gitflow/references/commit-message-generation.md +58 -0
  174. package/templates/skills/gitflow/references/commit-migration-validation.md +49 -0
  175. package/templates/skills/gitflow/references/finish-cleanup.md +51 -0
  176. package/templates/skills/gitflow/references/finish-version-bumping.md +45 -0
  177. package/templates/skills/gitflow/references/init-environment-detection.md +41 -0
  178. package/templates/skills/gitflow/references/init-questions.md +185 -0
  179. package/templates/skills/gitflow/references/init-structure-creation.md +71 -0
  180. package/templates/skills/gitflow/references/init-version-detection.md +21 -0
  181. package/templates/skills/gitflow/references/init-workspace-detection.md +43 -0
  182. package/templates/skills/gitflow/references/merge-ci-status.md +36 -0
  183. package/templates/skills/gitflow/references/merge-execution.md +62 -0
  184. package/templates/skills/gitflow/references/merge-pr-context.md +76 -0
  185. package/templates/skills/gitflow/references/pr-build-checks.md +60 -0
  186. package/templates/skills/gitflow/references/pr-generation.md +58 -0
  187. package/templates/skills/gitflow/references/start-branch-normalization.md +28 -0
  188. package/templates/skills/gitflow/references/start-worktree-creation.md +50 -0
  189. package/templates/skills/gitflow/references/sync-push-verify.md +44 -0
  190. package/templates/skills/gitflow/references/sync-rebase-conflicts.md +38 -0
  191. package/templates/skills/gitflow/steps/step-commit.md +12 -91
  192. package/templates/skills/gitflow/steps/step-finish.md +15 -159
  193. package/templates/skills/gitflow/steps/step-init.md +24 -326
  194. package/templates/skills/gitflow/steps/step-merge.md +17 -176
  195. package/templates/skills/gitflow/steps/step-pr.md +10 -116
  196. package/templates/skills/gitflow/steps/step-start.md +16 -109
  197. package/templates/skills/gitflow/steps/step-sync.md +6 -69
  198. package/templates/skills/ralph-loop/SKILL.md +6 -0
  199. package/templates/skills/ralph-loop/references/category-completeness.md +185 -0
  200. package/templates/skills/ralph-loop/references/compact-loop.md +1 -1
  201. package/templates/skills/ralph-loop/references/init-resume-recovery.md +127 -0
  202. package/templates/skills/ralph-loop/references/module-transition.md +151 -0
  203. package/templates/skills/ralph-loop/references/multi-module-queue.md +171 -0
  204. package/templates/skills/ralph-loop/references/parallel-execution.md +246 -0
  205. package/templates/skills/ralph-loop/references/task-transform-legacy.md +6 -9
  206. package/templates/skills/ralph-loop/references/team-orchestration.md +45 -3
  207. package/templates/skills/ralph-loop/steps/step-00-init.md +36 -109
  208. package/templates/skills/ralph-loop/steps/step-01-task.md +15 -163
  209. package/templates/skills/ralph-loop/steps/step-02-execute.md +8 -154
  210. package/templates/skills/ralph-loop/steps/step-04-check.md +21 -73
  211. package/templates/skills/review-code/references/owasp-api-top10.md +5 -5
  212. package/templates/skills/review-code/references/smartstack-conventions.md +11 -11
  213. package/templates/skills/validate-feature/references/api-smoke-tests.md +140 -0
  214. package/templates/skills/validate-feature/references/db-validation-checks.md +180 -0
  215. package/templates/skills/validate-feature/steps/step-01-compile.md +5 -2
  216. package/templates/skills/validate-feature/steps/step-04-api-smoke.md +34 -145
  217. package/templates/skills/validate-feature/steps/step-05-db-validation.md +74 -260
  218. package/templates/skills/workflow/SKILL.md +1 -1
  219. package/templates/skills/workflow/steps/step-00-init.md +57 -0
@@ -7,329 +7,143 @@ next_step: null
7
7
 
8
8
  # Step 5: Database Validation (SQL Server LocalDB)
9
9
 
10
- > **Purpose:** Verify that migrations apply correctly, seed data inserts, LINQ queries execute real SQL, and multi-tenant isolation works on a REAL SQL Server instance — not SQLite.
10
+ > **Purpose:** Verify migrations apply correctly, seed data inserts, LINQ queries execute on SQL Server, multi-tenant isolation works on REAL SQL Server (not SQLite).
11
+
12
+ See `references/db-validation-checks.md` for detailed checks, error classification, and fixes.
11
13
 
12
14
  ---
13
15
 
14
- ## 1. Verify LocalDB Availability
16
+ ## Procedure
17
+
18
+ ### Check 1: LocalDB Available?
15
19
 
16
20
  ```bash
17
21
  sqllocaldb info MSSQLLocalDB
18
22
  ```
19
23
 
20
- **If LocalDB is NOT available:**
21
- - Display warning: `LocalDB not found — skipping DB validation`
22
- - Set `DB_VALIDATION = SKIPPED`
23
- - Skip to section 8 (Summary)
24
-
25
- **If LocalDB is available:**
26
- - Continue to section 2
27
-
28
- ---
24
+ If NOT available Skip DB validation, set `DB_VALIDATION = SKIPPED`
29
25
 
30
- ## 2. Locate Infrastructure Project
26
+ ### Check 2: Pending Model Changes?
31
27
 
32
28
  ```bash
33
- INFRA_PROJECT=$(ls src/*Infrastructure*/*.csproj 2>/dev/null | head -1)
34
- API_PROJECT=$(ls src/*Api*/*.csproj 2>/dev/null | head -1)
35
-
36
- if [ -z "$INFRA_PROJECT" ] || [ -z "$API_PROJECT" ]; then
37
- echo "WARNING: Infrastructure or API project not found — skipping DB validation"
38
- DB_VALIDATION="SKIPPED"
39
- # Skip to section 8
40
- fi
29
+ dotnet ef migrations has-pending-model-changes --project "$INFRA_PROJECT" --startup-project "$API_PROJECT"
41
30
  ```
42
31
 
43
- ---
44
-
45
- ## 3. Check Pending Model Changes
46
-
32
+ If exit code != 0 → Create missing migration:
47
33
  ```bash
48
- dotnet ef migrations has-pending-model-changes \
49
- --project "$INFRA_PROJECT" \
50
- --startup-project "$API_PROJECT"
34
+ dotnet ef migrations add {SuggestedName} --project {InfraProject} --startup-project {ApiProject} -o Persistence/Migrations
51
35
  ```
52
36
 
53
- | Exit Code | Meaning | Action |
54
- |-----------|---------|--------|
55
- | 0 | No pending changes | PASS — continue |
56
- | Non-zero | Model has changes not in a migration | **FAIL — BLOCKING** |
57
-
58
- **If FAIL:**
59
- - Display: `MIGRATION MISSING: EF Core model has changes not captured in a migration`
60
- - Provide fix: `dotnet ef migrations add {SuggestedName} --project {InfraProject} --startup-project {ApiProject} -o Persistence/Migrations`
61
- - **BLOCK** — do NOT continue until migration is created
62
-
63
- ---
64
-
65
- ## 4. Apply Migrations on Temp Database
37
+ ### Check 3: Apply Migrations on Temp DB
66
38
 
67
39
  ```bash
68
- # Create unique test database name
69
40
  DB_NAME="SmartStack_Validate_$(date +%s)"
70
41
  CONN_STRING="Server=(localdb)\\MSSQLLocalDB;Database=$DB_NAME;Integrated Security=true;TrustServerCertificate=true;Connect Timeout=120;"
71
42
 
72
- # Apply ALL migrations from scratch
73
- dotnet ef database update \
74
- --connection "$CONN_STRING" \
75
- --project "$INFRA_PROJECT" \
76
- --startup-project "$API_PROJECT"
43
+ dotnet ef database update --connection "$CONN_STRING" --project "$INFRA_PROJECT" --startup-project "$API_PROJECT"
77
44
  ```
78
45
 
79
- | Result | Meaning | Action |
80
- |--------|---------|--------|
81
- | Success | All migrations apply cleanly | PASS — continue |
82
- | Failure | Migration chain is broken | **FAIL — BLOCKING** |
46
+ If FAIL Check for: migration ordering, duplicate migration, seed data conflict (see reference)
83
47
 
84
- **If FAIL:**
85
- - Parse the error output
86
- - Common issues:
87
- - `Invalid column name` → migration references a column that doesn't exist yet (ordering issue)
88
- - `There is already an object named` → duplicate migration or missing Down() method
89
- - `Cannot insert duplicate key` → seed data in migration conflicting
90
- - **BLOCK** — fix the migration before continuing
91
-
92
- ---
93
-
94
- ## 5. Run Integration Tests Against Real SQL Server
48
+ ### Check 4: Integration Tests (SQL Server)
95
49
 
96
50
  ```bash
97
- # Find integration test project
98
51
  TEST_PROJECT=$(ls tests/*Tests.Integration*/*.csproj 2>/dev/null | head -1)
99
-
100
- if [ -n "$TEST_PROJECT" ]; then
101
- # Integration tests use DatabaseFixture which creates its own LocalDB instance
102
- # and applies real migrations — this validates LINQ → SQL translation
103
- dotnet test "$TEST_PROJECT" --no-build --verbosity normal
104
- else
105
- echo "INFO: No integration test project found — running unit tests only"
106
- TEST_PROJECT=$(ls tests/*Tests*/*.csproj 2>/dev/null | head -1)
107
- if [ -n "$TEST_PROJECT" ]; then
108
- dotnet test "$TEST_PROJECT" --filter "FullyQualifiedName~Integration" --no-build --verbosity normal
109
- fi
110
- fi
52
+ dotnet test "$TEST_PROJECT" --no-build --verbosity normal
111
53
  ```
112
54
 
113
- **What this validates:**
114
- - **LINQ → SQL**: Queries execute against real SQL Server, not SQLite
115
- - **Multi-tenant isolation**: Global query filters enforced at SQL Server level
116
- - **Soft delete**: SQL Server handles IsDeleted filter correctly
117
- - **EF Core configuration**: Indexes, relationships, constraints verified
118
- - **Repository operations**: CRUD operations hit real SQL Server
119
-
120
- | Result | Meaning |
121
- |--------|---------|
122
- | All tests pass | PASS — LINQ→SQL, isolation, and EF configs work on real SQL Server |
123
- | Test failures | **FAIL** — investigate: some queries may not translate to SQL Server |
124
-
125
- **Common SQLite → SQL Server differences caught:**
126
- - `LIKE` is case-insensitive in SQLite, case-sensitive in SQL Server
127
- - Date functions differ (`date('now')` vs `GETUTCDATE()`)
128
- - String concatenation (`||` vs `+`)
129
- - `LIMIT` vs `TOP`
130
- - `AUTOINCREMENT` vs `IDENTITY`
131
- - `COLLATE` behavior differences
132
-
133
- ---
55
+ Validates: LINQ→SQL, multi-tenant isolation, soft delete, EF configs, repositories on real SQL Server
134
56
 
135
- ## 5b. Verify Dev Seeding Configuration
136
-
137
- Before checking seed data, verify that dev seeding is actually enabled:
57
+ ### Check 5: Dev Seeding Enabled?
138
58
 
139
59
  ```bash
140
- # Check 1: EnableDevSeeding in appsettings
141
- APPSETTINGS_DEV=$(ls appsettings.Development.json 2>/dev/null || ls src/*Api*/appsettings.Development.json 2>/dev/null)
142
- APPSETTINGS_BASE=$(ls appsettings.json 2>/dev/null || ls src/*Api*/appsettings.json 2>/dev/null)
143
-
144
- SEEDING_EXPLICIT_TRUE=false
145
- SEEDING_EXPLICIT_FALSE=false
146
-
147
- # Check Development appsettings first (overrides base)
148
- if [ -n "$APPSETTINGS_DEV" ]; then
149
- if grep -q '"EnableDevSeeding".*true' "$APPSETTINGS_DEV" 2>/dev/null; then
150
- SEEDING_EXPLICIT_TRUE=true
151
- fi
152
- fi
153
-
154
- # Check base appsettings
155
- if [ -n "$APPSETTINGS_BASE" ] && [ "$SEEDING_EXPLICIT_TRUE" = "false" ]; then
156
- if grep -q '"EnableDevSeeding".*false' "$APPSETTINGS_BASE" 2>/dev/null; then
157
- SEEDING_EXPLICIT_FALSE=true
158
- fi
159
- fi
160
-
161
- # Check 2: Program.cs override pattern
60
+ APPSETTINGS=$(ls appsettings.Development.json 2>/dev/null || ls appsettings.json 2>/dev/null)
162
61
  PROGRAM_CS=$(find . -name "Program.cs" -path "*/Api/*" 2>/dev/null | head -1)
163
- PROGRAM_OVERRIDE=false
164
- if [ -n "$PROGRAM_CS" ]; then
165
- if grep -q 'EnableDevSeeding.*IsDevelopment\|IsDevelopment.*EnableDevSeeding' "$PROGRAM_CS" 2>/dev/null; then
166
- PROGRAM_OVERRIDE=true
167
- fi
168
- fi
169
-
170
- # Evaluate
171
- if [ "$SEEDING_EXPLICIT_FALSE" = "true" ] && [ "$PROGRAM_OVERRIDE" = "false" ]; then
172
- echo "⚠️ WARNING: EnableDevSeeding is FALSE in appsettings.json and NO Program.cs override detected"
173
- echo "DevDataSeeder will NOT execute — test data will be empty"
174
- echo "Fix option 1: Add to appsettings.Development.json: \"EnableDevSeeding\": true"
175
- echo "Fix option 2: Add to Program.cs: options.EnableDevSeeding = builder.Environment.IsDevelopment();"
176
- SEEDING_ENABLED=false
177
- elif [ "$PROGRAM_OVERRIDE" = "true" ]; then
178
- echo "✓ EnableDevSeeding: Program.cs overrides to IsDevelopment() — active in Development"
179
- SEEDING_ENABLED=true
180
- else
181
- echo "✓ EnableDevSeeding: explicitly enabled"
182
- SEEDING_ENABLED=true
183
- fi
184
- ```
185
62
 
186
- | Result | Meaning | Action |
187
- |--------|---------|--------|
188
- | Program.cs override detected | PASS | Dev seeding active in Development environment |
189
- | Explicitly enabled | PASS | Dev seeding active |
190
- | FALSE + no override | **WARNING** | DevDataSeeder won't run — seed data checks in section 6 will likely fail |
63
+ # Check for Program.cs override or appsettings EnableDevSeeding = true
64
+ ```
191
65
 
192
- ---
66
+ If not enabled → Add to Program.cs:
67
+ ```csharp
68
+ options.EnableDevSeeding = builder.Environment.IsDevelopment();
69
+ ```
193
70
 
194
- ## 6. Verify Seed Data Execution
71
+ ### Check 6: DefaultTenantId FK Validation
195
72
 
196
73
  ```bash
197
- # Use the test database from step 4 to verify seed data
198
- # Start the API against the temp database
199
- dotnet run --project "$API_PROJECT" \
200
- --urls "http://localhost:5097" \
201
- -- --ConnectionStrings:DefaultConnection="$CONN_STRING" > /tmp/validate-seed-check.log 2>&1 &
202
- SEED_PID=$!
203
-
204
- # Wait for startup
205
- STARTED=false
206
- for i in $(seq 1 15); do
207
- if ! kill -0 $SEED_PID 2>/dev/null; then
208
- echo "API crashed during startup with seed data"
209
- break
210
- fi
211
- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5097/health 2>/dev/null)
212
- if [ "$HTTP_CODE" != "000" ]; then
213
- STARTED=true
214
- break
215
- fi
216
- sleep 1
217
- done
218
-
219
- if [ "$STARTED" = "true" ]; then
220
- # Verify seed data exists by checking API endpoints
221
- # Login with test credentials
222
- TOKEN=$(curl -s -X POST http://localhost:5097/api/auth/login \
223
- -H "Content-Type: application/json" \
224
- -d '{"email":"admin@smartstack.io","password":"Admin123!"}' \
225
- | grep -o '"accessToken":"[^"]*' | cut -d'"' -f4)
226
-
227
- if [ -n "$TOKEN" ]; then
228
- # Check navigation modules exist (core seed data)
229
- NAV_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5097/api/platform/navigation/modules \
230
- -H "Authorization: Bearer $TOKEN" \
231
- -H "X-Tenant-Id: 11111111-1111-1111-1111-111111111111")
232
-
233
- if [ "$NAV_STATUS" = "200" ]; then
234
- echo "PASS: Core seed data verified (navigation modules accessible)"
235
- else
236
- echo "WARNING: Core seed data may not be seeded (HTTP $NAV_STATUS)"
237
- fi
238
- else
239
- echo "WARNING: Could not authenticate — seed data verification via API skipped"
240
- echo "INFO: Integration tests already verify seed data at DB level via DatabaseFixture"
241
- fi
242
- fi
243
-
244
- # --- DefaultTenantId cross-schema FK validation ---
245
- # Verify that SeedConstants.DefaultTenantId exists in core.tenant_Tenants
246
74
  SEED_CONSTANTS=$(find . -path "*/SeedConstants.cs" 2>/dev/null | head -1)
247
- if [ -n "$SEED_CONSTANTS" ]; then
248
- TENANT_GUID=$(grep -oP 'DefaultTenantId\s*=\s*Guid\.Parse\("([^"]+)"\)' "$SEED_CONSTANTS" | grep -oP '"[^"]+"' | tr -d '"')
249
-
250
- if [ -n "$TENANT_GUID" ] && [ -n "$DB_NAME" ]; then
251
- TENANT_EXISTS=$(sqlcmd -S "(localdb)\MSSQLLocalDB" -d "$DB_NAME" -Q "
252
- SET NOCOUNT ON;
253
- SELECT COUNT(*) FROM core.tenant_Tenants WHERE Id = '$TENANT_GUID'
254
- " -h -1 2>/dev/null | tr -d ' ')
255
-
256
- if [ "$TENANT_EXISTS" = "0" ]; then
257
- echo "❌ FAIL: SeedConstants.DefaultTenantId ($TENANT_GUID) does NOT exist in core.tenant_Tenants"
258
- echo "DevDataSeeder inserts rows with an invalid FK — causes runtime 500 errors"
259
- echo "Fix: Use a TenantId that is seeded by InitializeSmartStackAsync()"
260
- else
261
- echo "✓ DefaultTenantId ($TENANT_GUID) exists in core.tenant_Tenants"
262
- fi
263
- fi
264
- fi
265
-
266
- # Cleanup
267
- kill $SEED_PID 2>/dev/null
268
- wait $SEED_PID 2>/dev/null
269
- rm -f /tmp/validate-seed-check.log
75
+ TENANT_GUID=$(grep -oP 'DefaultTenantId\s*=\s*Guid\.Parse\("([^"]+)"\)' "$SEED_CONSTANTS" | grep -oP '"[^"]+"' | tr -d '"')
76
+
77
+ sqlcmd -S "(localdb)\MSSQLLocalDB" -d "$DB_NAME" -Q "
78
+ SET NOCOUNT ON;
79
+ SELECT COUNT(*) FROM core.tenant_Tenants WHERE Id = '$TENANT_GUID'
80
+ "
270
81
  ```
271
82
 
272
- ---
83
+ If COUNT = 0 → Use a TenantId seeded by `InitializeSmartStackAsync()`
273
84
 
274
- ## 7. Cleanup Temp Database
85
+ ### Check 7: Seed Data Accessible?
86
+
87
+ ```bash
88
+ dotnet run --project "$API_PROJECT" --urls "http://localhost:5097" \
89
+ -- --ConnectionStrings:DefaultConnection="$CONN_STRING" &
90
+
91
+ # Verify seed data via API endpoint
92
+ # (See reference for full commands)
93
+ ```
94
+
95
+ ### Check 8: Cleanup
275
96
 
276
97
  ```bash
277
- # Drop the temp database created in step 4
278
98
  sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "
279
99
  IF DB_ID('$DB_NAME') IS NOT NULL
280
100
  BEGIN
281
101
  ALTER DATABASE [$DB_NAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
282
102
  DROP DATABASE [$DB_NAME];
283
103
  END
284
- " 2>/dev/null
285
-
286
- # Alternative if sqlcmd is not available
287
- if [ $? -ne 0 ]; then
288
- dotnet ef database drop --force \
289
- --connection "$CONN_STRING" \
290
- --project "$INFRA_PROJECT" \
291
- --startup-project "$API_PROJECT" 2>/dev/null
292
- fi
104
+ "
293
105
  ```
294
106
 
295
107
  ---
296
108
 
297
- ## 8. Validation Summary
109
+ ## Validation Summary
298
110
 
299
111
  ```
300
112
  ## DB Validation: {EntityName}
301
113
 
302
- | Check | Result | Details |
303
- |--------------------------------|-----------|--------------------------------------------|
304
- | LocalDB available | PASS/SKIP | sqllocaldb info MSSQLLocalDB |
305
- | Pending model changes | PASS/FAIL | dotnet ef migrations has-pending |
306
- | Migrations apply cleanly | PASS/FAIL | dotnet ef database update on temp DB |
307
- | Integration tests (SQL Server) | PASS/FAIL | dotnet test --filter Integration |
308
- | EnableDevSeeding active | PASS/WARN | Program.cs override or appsettings check |
309
- | DefaultTenantId FK valid | PASS/FAIL | SeedConstants GUID exists in tenant_Tenants|
310
- | Seed data accessible | PASS/WARN | API endpoints return seeded data |
311
- | Temp DB cleanup | PASS/WARN | Database dropped |
114
+ | Check | Result | Details |
115
+ |-------|--------|---------|
116
+ | LocalDB available | PASS/SKIP | sqllocaldb info MSSQLLocalDB |
117
+ | Pending model changes | PASS/FAIL | dotnet ef migrations has-pending |
118
+ | Migrations apply cleanly | PASS/FAIL | dotnet ef database update on temp DB |
119
+ | Integration tests (SQL Server) | PASS/FAIL | dotnet test --filter Integration |
120
+ | EnableDevSeeding active | PASS/WARN | Program.cs override or appsettings |
121
+ | DefaultTenantId FK valid | PASS/FAIL | SeedConstants GUID exists in tenant_Tenants |
122
+ | Seed data accessible | PASS/WARN | API endpoints return seeded data |
123
+ | Temp DB cleanup | PASS/WARN | Database dropped |
312
124
 
313
125
  DB Validation Result: {PASS / FAIL / SKIPPED}
314
126
  ```
315
127
 
316
128
  **Interpretation:**
317
- - **PASS**: All 8 checks covered migrations, SQL Server, LINQ→SQL, isolation, seeding config, tenant FK, seed data verified
318
- - **FAIL**: One or more checks failed fix before committing
319
- - **SKIPPED**: LocalDB not available — tests ran on SQLite only (partial coverage)
129
+ - **PASS** All checks covered: migrations, SQL Server, LINQ→SQL, isolation, seeding config
130
+ - **FAIL**Fix before committing
131
+ - **SKIPPED** LocalDB unavailable; tests ran on SQLite only (partial coverage)
132
+
133
+ ---
134
+
135
+ ## Error Reference
136
+
137
+ See `references/db-validation-checks.md` for complete error classification and fixes including:
138
+ - Migration ordering issues
139
+ - Seed data conflicts
140
+ - ForeignKey constraint violations
141
+ - LocalDB connectivity
142
+ - EnableDevSeeding configuration
143
+ - DefaultTenantId phantom FK
320
144
 
321
145
  ---
322
146
 
323
- ## Error Classification (DB-specific)
324
-
325
- | Error Pattern | Category | Fix |
326
- |---------------|----------|-----|
327
- | `Invalid column name '{Column}'` | Migration ordering | Reorder migration or split into multiple |
328
- | `Cannot insert duplicate key` | Seed data conflict | Make seed data idempotent (check before insert) |
329
- | `String or binary data would be truncated` | Column length | Increase `MaxLength` in EF config |
330
- | `The INSERT statement conflicted with the FOREIGN KEY constraint` | Missing parent data | Ensure parent entities are seeded first |
331
- | `Cannot insert the value NULL into column` | Missing NOT NULL | Add default value or make column nullable |
332
- | `Login failed for user` | LocalDB auth | Run `sqllocaldb start MSSQLLocalDB` |
333
- | `A network-related or instance-specific error` | LocalDB not running | Run `sqllocaldb start MSSQLLocalDB` |
334
- | `DefaultTenantId does NOT exist in core.tenant_Tenants` | Phantom FK | Use a TenantId seeded by `InitializeSmartStackAsync()` |
335
- | `EnableDevSeeding is FALSE` + empty tables | Seeding disabled | Add `options.EnableDevSeeding = builder.Environment.IsDevelopment()` in Program.cs |
147
+ ## NEXT STEP:
148
+
149
+ DB validation complete. Review all step results and generate final report.
@@ -64,7 +64,7 @@ await _workflowService.TriggerAsync("entity.event", new Dictionary<string, objec
64
64
 
65
65
  ## Implementation
66
66
 
67
- See [steps/step-01-implementation.md](steps/step-01-implementation.md) for:
67
+ Start with [steps/step-00-init.md](steps/step-00-init.md) to identify workflow triggers and requirements, then proceed to [steps/step-01-implementation.md](steps/step-01-implementation.md) for:
68
68
  - Step types (SendEmail, Wait, Condition, Webhook) with code templates
69
69
  - Workflow creation and seed data
70
70
  - Triggering from services
@@ -0,0 +1,57 @@
1
+ # Step 0: Initialization
2
+
3
+ ## YOUR TASK
4
+ Gather workflow requirements and identify triggers before implementing automated processes.
5
+
6
+ ## EXECUTION SEQUENCE
7
+
8
+ ### 1. Identify Workflow Type
9
+ - What event triggers this workflow? (user.registered, entity.created, status.changed, time-based)
10
+ - What business process should be automated? (email sequence, multi-step approval, notification chain)
11
+ - What is the primary action? (SendEmail, Webhook, Condition logic, Wait/delay)
12
+ - Is this a new trigger or does it use an existing one? (check WorkflowTriggerConfiguration.cs)
13
+
14
+ ### 2. Define Workflow Variables
15
+ - What variables are available from the trigger event?
16
+ - Example: `user.registered` provides userId, email, displayName, confirmUrl
17
+ - Example: `ticket.created` provides ticketId, ticketNumber, title, creatorEmail
18
+ - What variables are needed in steps? (recipients, delays, conditions, webhook payloads)
19
+ - Map all {{variable}} placeholders to available data
20
+
21
+ ### 3. Plan Workflow Steps
22
+ - Step 1: SendEmail? Webhook? Condition? Wait/Delay?
23
+ - Step 2: Follow-up action after first step
24
+ - Step 3+: Conditional branches or multi-step sequences
25
+ - Error handling: what happens if a step fails? (retry, fallback, notify)
26
+ - Timeout: should the workflow have a maximum duration?
27
+
28
+ ### 4. Design Email Templates (if SendEmail steps)
29
+ - Email subject and body templates
30
+ - Handlebars syntax for variable interpolation: `{{userId}}`, `{{confirmUrl}}`
31
+ - HTML and plain text versions if needed
32
+ - i18n translations: French, English, Italian, German
33
+ - Template registration in EmailTemplateConfiguration.cs
34
+
35
+ ### 5. Check Trigger Configuration
36
+ - Does the trigger exist in WorkflowTriggerConfiguration.cs?
37
+ - If new trigger:
38
+ - Define available variables (JSON serialized array)
39
+ - Add trigger seed data with unique code (kebab-case)
40
+ - Plan where in code to call `IWorkflowService.TriggerAsync(code, variables)`
41
+
42
+ ### 6. Define Logging & Monitoring
43
+ - What execution events should be logged?
44
+ - How to track workflow success/failure metrics?
45
+ - What observability is needed for debugging?
46
+
47
+ ## SUCCESS METRICS
48
+ - Workflow trigger identified or new trigger planned
49
+ - Available variables from trigger documented
50
+ - Workflow steps sequenced (SendEmail -> Wait -> Condition -> Webhook, etc.)
51
+ - Email templates designed with i18n
52
+ - Trigger configuration understood (existing or new)
53
+ - Integration point in code identified (where TriggerAsync is called)
54
+ - Error handling strategy defined
55
+
56
+ ## NEXT STEP
57
+ Proceed to `./step-01-implementation.md` to implement workflow entity, steps, trigger configuration, email templates, and integration into services with IWorkflowService.