@atlashub/smartstack-cli 3.37.0 → 3.39.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 (228) hide show
  1. package/dist/index.js +16 -24
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +235 -265
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/scripts/extract-api-endpoints.ts +5 -5
  7. package/scripts/generate-doc-with-mock-ui.ts +10 -17
  8. package/templates/agents/ba-reader.md +9 -9
  9. package/templates/agents/ba-writer.md +12 -15
  10. package/templates/agents/code-reviewer.md +1 -1
  11. package/templates/agents/docs-context-reader.md +1 -1
  12. package/templates/agents/efcore/scan.md +3 -1
  13. package/templates/agents/gitflow/commit.md +74 -0
  14. package/templates/agents/gitflow/finish.md +5 -2
  15. package/templates/agents/gitflow/init-clone.md +3 -3
  16. package/templates/agents/gitflow/init-validate.md +3 -2
  17. package/templates/agents/gitflow/merge.md +5 -4
  18. package/templates/agents/gitflow/pr.md +5 -4
  19. package/templates/agents/gitflow/start.md +37 -5
  20. package/templates/hooks/hooks.json +11 -0
  21. package/templates/hooks/wsl-dotnet-cleanup.sh +24 -0
  22. package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +20 -20
  23. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +16 -24
  24. package/templates/mcp-scaffolding/migrations/seed-roles.cs.hbs +2 -2
  25. package/templates/skills/_resources/mcp-validate-documentation-spec.md +3 -3
  26. package/templates/skills/_shared.md +15 -17
  27. package/templates/skills/ai-prompt/SKILL.md +1 -1
  28. package/templates/skills/ai-prompt/steps/step-00-init.md +47 -0
  29. package/templates/skills/apex/SKILL.md +3 -4
  30. package/templates/skills/apex/_shared.md +10 -20
  31. package/templates/skills/apex/references/analysis-methods.md +141 -0
  32. package/templates/skills/apex/references/challenge-questions.md +1 -21
  33. package/templates/skills/apex/references/core-seed-data.md +35 -58
  34. package/templates/skills/apex/references/examine-build-validation.md +82 -0
  35. package/templates/skills/apex/references/execution-frontend-gates.md +177 -0
  36. package/templates/skills/apex/references/execution-frontend-patterns.md +105 -0
  37. package/templates/skills/apex/references/execution-layer1-rules.md +96 -0
  38. package/templates/skills/apex/references/initialization-challenge-flow.md +110 -0
  39. package/templates/skills/apex/references/planning-layer-mapping.md +151 -0
  40. package/templates/skills/apex/references/post-checks.md +145 -40
  41. package/templates/skills/apex/references/smartstack-api.md +35 -51
  42. package/templates/skills/apex/references/smartstack-frontend.md +18 -18
  43. package/templates/skills/apex/references/smartstack-layers.md +38 -62
  44. package/templates/skills/apex/steps/step-00-init.md +14 -26
  45. package/templates/skills/apex/steps/step-01-analyze.md +10 -143
  46. package/templates/skills/apex/steps/step-02-plan.md +10 -92
  47. package/templates/skills/apex/steps/step-03-execute.md +45 -252
  48. package/templates/skills/apex/steps/step-04-examine.md +14 -78
  49. package/templates/skills/apex/steps/step-05-deep-review.md +2 -2
  50. package/templates/skills/apex/steps/step-08-run-tests.md +1 -0
  51. package/templates/skills/application/SKILL.md +241 -242
  52. package/templates/skills/application/references/backend-controller-hierarchy.md +16 -16
  53. package/templates/skills/application/references/backend-seeding-and-dto-output.md +83 -0
  54. package/templates/skills/application/references/backend-table-prefix-mapping.md +79 -0
  55. package/templates/skills/application/references/backend-verification.md +1 -1
  56. package/templates/skills/application/references/frontend-i18n-and-output.md +67 -0
  57. package/templates/skills/application/references/frontend-route-naming.md +117 -0
  58. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +107 -0
  59. package/templates/skills/application/references/frontend-verification.md +12 -12
  60. package/templates/skills/application/references/init-parameter-detection.md +121 -0
  61. package/templates/skills/application/references/migration-checklist-troubleshooting.md +100 -0
  62. package/templates/skills/application/references/nav-fallback-procedure.md +199 -200
  63. package/templates/skills/application/references/provider-template.md +2 -6
  64. package/templates/skills/application/references/roles-client-project-handling.md +55 -0
  65. package/templates/skills/application/references/roles-fallback-procedure.md +149 -0
  66. package/templates/skills/application/references/test-coverage-requirements.md +213 -0
  67. package/templates/skills/application/references/test-frontend.md +3 -3
  68. package/templates/skills/application/steps/step-00-init.md +130 -260
  69. package/templates/skills/application/steps/step-01-navigation.md +170 -170
  70. package/templates/skills/application/steps/step-02-permissions.md +196 -196
  71. package/templates/skills/application/steps/step-03-roles.md +182 -339
  72. package/templates/skills/application/steps/step-03b-provider.md +133 -134
  73. package/templates/skills/application/steps/step-04-backend.md +174 -265
  74. package/templates/skills/application/steps/step-05-frontend.md +18 -144
  75. package/templates/skills/application/steps/step-06-migration.md +12 -60
  76. package/templates/skills/application/steps/step-07-tests.md +9 -76
  77. package/templates/skills/application/templates-backend.md +29 -27
  78. package/templates/skills/application/templates-frontend.md +49 -49
  79. package/templates/skills/application/templates-seed.md +57 -131
  80. package/templates/skills/business-analyse/SKILL.md +27 -30
  81. package/templates/skills/business-analyse/_architecture.md +6 -6
  82. package/templates/skills/business-analyse/_shared.md +60 -88
  83. package/templates/skills/business-analyse/questionnaire/04-data.md +3 -3
  84. package/templates/skills/business-analyse/questionnaire/06-security.md +1 -1
  85. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +1 -1
  86. package/templates/skills/business-analyse/react/application-viewer.md +12 -12
  87. package/templates/skills/business-analyse/react/components.md +8 -12
  88. package/templates/skills/business-analyse/react/schema.md +836 -836
  89. package/templates/skills/business-analyse/references/agent-module-prompt.md +2 -3
  90. package/templates/skills/business-analyse/references/analysis-semantic-checks.md +190 -0
  91. package/templates/skills/business-analyse/references/cache-warming-strategy.md +2 -2
  92. package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +41 -0
  93. package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +74 -0
  94. package/templates/skills/business-analyse/references/cadrage-shared-modules.md +69 -0
  95. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +1 -1
  96. package/templates/skills/business-analyse/references/compilation-structure-cards.md +297 -0
  97. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +2 -2
  98. package/templates/skills/business-analyse/references/deploy-modes.md +5 -5
  99. package/templates/skills/business-analyse/references/detection-strategies.md +7 -7
  100. package/templates/skills/business-analyse/references/handoff-file-templates.md +14 -22
  101. package/templates/skills/business-analyse/references/handoff-mappings.md +4 -4
  102. package/templates/skills/business-analyse/references/handoff-seeddata-generation.md +312 -0
  103. package/templates/skills/business-analyse/references/init-schema-deployment.md +3 -3
  104. package/templates/skills/business-analyse/references/naming-conventions.md +22 -24
  105. package/templates/skills/business-analyse/references/prd-generation.md +2 -2
  106. package/templates/skills/business-analyse/references/review-data-mapping.md +2 -2
  107. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  108. package/templates/skills/business-analyse/references/spec-auto-inference.md +3 -3
  109. package/templates/skills/business-analyse/references/team-orchestration.md +49 -6
  110. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
  111. package/templates/skills/business-analyse/references/ui-resource-cards.md +18 -18
  112. package/templates/skills/business-analyse/references/validate-incremental-html.md +2 -2
  113. package/templates/skills/business-analyse/references/validation-checklist.md +2 -2
  114. package/templates/skills/business-analyse/schemas/application-schema.json +4 -5
  115. package/templates/skills/business-analyse/schemas/project-schema.json +1 -6
  116. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +2 -3
  117. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +4 -4
  118. package/templates/skills/business-analyse/steps/step-00-init.md +8 -17
  119. package/templates/skills/business-analyse/steps/step-01-cadrage.md +35 -198
  120. package/templates/skills/business-analyse/steps/step-01b-applications.md +16 -20
  121. package/templates/skills/business-analyse/steps/step-02-decomposition.md +1 -1
  122. package/templates/skills/business-analyse/steps/step-03a1-setup.md +4 -4
  123. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +1 -1
  124. package/templates/skills/business-analyse/steps/step-03b-ui.md +4 -4
  125. package/templates/skills/business-analyse/steps/step-03c-compile.md +66 -140
  126. package/templates/skills/business-analyse/steps/step-03d-validate.md +2 -2
  127. package/templates/skills/business-analyse/steps/step-04a-collect.md +2 -2
  128. package/templates/skills/business-analyse/steps/step-04b-analyze.md +42 -160
  129. package/templates/skills/business-analyse/steps/step-04c-decide.md +1 -1
  130. package/templates/skills/business-analyse/steps/step-05a-handoff.md +74 -104
  131. package/templates/skills/business-analyse/steps/step-05b-deploy.md +13 -11
  132. package/templates/skills/business-analyse/steps/step-06-review.md +3 -3
  133. package/templates/skills/business-analyse/templates/tpl-frd.md +13 -13
  134. package/templates/skills/business-analyse/templates/tpl-handoff.md +12 -12
  135. package/templates/skills/business-analyse/templates/tpl-progress.md +1 -1
  136. package/templates/skills/business-analyse/templates-frd.md +25 -25
  137. package/templates/skills/business-analyse/templates-react.md +15 -21
  138. package/templates/skills/controller/SKILL.md +1 -1
  139. package/templates/skills/controller/postman-templates.md +1 -1
  140. package/templates/skills/controller/references/controller-code-templates.md +2 -2
  141. package/templates/skills/controller/references/mcp-scaffold-workflow.md +209 -0
  142. package/templates/skills/controller/references/permission-sync-templates.md +13 -16
  143. package/templates/skills/controller/steps/step-00-init.md +11 -11
  144. package/templates/skills/controller/steps/step-03-generate.md +64 -103
  145. package/templates/skills/controller/templates.md +67 -71
  146. package/templates/skills/debug/SKILL.md +13 -218
  147. package/templates/skills/debug/steps/step-00-init.md +57 -0
  148. package/templates/skills/debug/steps/step-01-analyze.md +219 -0
  149. package/templates/skills/debug/steps/step-02-resolve.md +85 -0
  150. package/templates/skills/documentation/SKILL.md +49 -345
  151. package/templates/skills/documentation/data-schema.md +11 -8
  152. package/templates/skills/documentation/steps/step-00-init.md +70 -0
  153. package/templates/skills/documentation/steps/step-01-scan.md +113 -0
  154. package/templates/skills/documentation/steps/step-02-generate.md +231 -0
  155. package/templates/skills/documentation/steps/step-03-validate.md +238 -0
  156. package/templates/skills/documentation/templates.md +480 -322
  157. package/templates/skills/efcore/SKILL.md +1 -1
  158. package/templates/skills/efcore/references/both-contexts.md +32 -0
  159. package/templates/skills/efcore/references/database-operations.md +67 -0
  160. package/templates/skills/efcore/references/destructive-operations.md +38 -0
  161. package/templates/skills/efcore/references/reset-operations.md +81 -0
  162. package/templates/skills/efcore/references/seed-methods.md +86 -0
  163. package/templates/skills/efcore/references/shared-init-functions.md +250 -0
  164. package/templates/skills/efcore/references/sql-objects-injection.md +61 -0
  165. package/templates/skills/efcore/references/troubleshooting.md +81 -0
  166. package/templates/skills/efcore/steps/db/step-deploy.md +1 -32
  167. package/templates/skills/efcore/steps/db/step-reset.md +7 -103
  168. package/templates/skills/efcore/steps/db/step-seed.md +10 -132
  169. package/templates/skills/efcore/steps/db/step-status.md +5 -44
  170. package/templates/skills/efcore/steps/migration/step-02-create.md +1 -14
  171. package/templates/skills/efcore/steps/migration/step-03-validate.md +8 -62
  172. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +1 -57
  173. package/templates/skills/efcore/steps/shared/step-00-init.md +11 -254
  174. package/templates/skills/efcore/steps/squash/step-03-create.md +1 -58
  175. package/templates/skills/feature-full/SKILL.md +1 -1
  176. package/templates/skills/feature-full/steps/step-00-init.md +57 -0
  177. package/templates/skills/feature-full/steps/step-01-implementation.md +1 -1
  178. package/templates/skills/gitflow/SKILL.md +28 -5
  179. package/templates/skills/gitflow/_shared.md +109 -12
  180. package/templates/skills/gitflow/phases/abort.md +4 -0
  181. package/templates/skills/gitflow/phases/cleanup.md +4 -0
  182. package/templates/skills/gitflow/references/commit-message-generation.md +58 -0
  183. package/templates/skills/gitflow/references/commit-migration-validation.md +49 -0
  184. package/templates/skills/gitflow/references/finish-cleanup.md +55 -0
  185. package/templates/skills/gitflow/references/finish-version-bumping.md +45 -0
  186. package/templates/skills/gitflow/references/init-environment-detection.md +41 -0
  187. package/templates/skills/gitflow/references/init-questions.md +185 -0
  188. package/templates/skills/gitflow/references/init-structure-creation.md +75 -0
  189. package/templates/skills/gitflow/references/init-version-detection.md +21 -0
  190. package/templates/skills/gitflow/references/init-workspace-detection.md +43 -0
  191. package/templates/skills/gitflow/references/merge-ci-status.md +36 -0
  192. package/templates/skills/gitflow/references/merge-execution.md +62 -0
  193. package/templates/skills/gitflow/references/merge-pr-context.md +76 -0
  194. package/templates/skills/gitflow/references/pr-build-checks.md +60 -0
  195. package/templates/skills/gitflow/references/pr-generation.md +58 -0
  196. package/templates/skills/gitflow/references/start-branch-normalization.md +28 -0
  197. package/templates/skills/gitflow/references/start-worktree-creation.md +50 -0
  198. package/templates/skills/gitflow/references/sync-push-verify.md +44 -0
  199. package/templates/skills/gitflow/references/sync-rebase-conflicts.md +38 -0
  200. package/templates/skills/gitflow/steps/step-commit.md +12 -91
  201. package/templates/skills/gitflow/steps/step-finish.md +15 -159
  202. package/templates/skills/gitflow/steps/step-init.md +24 -326
  203. package/templates/skills/gitflow/steps/step-merge.md +17 -176
  204. package/templates/skills/gitflow/steps/step-pr.md +10 -116
  205. package/templates/skills/gitflow/steps/step-start.md +16 -109
  206. package/templates/skills/gitflow/steps/step-sync.md +6 -69
  207. package/templates/skills/ralph-loop/SKILL.md +6 -0
  208. package/templates/skills/ralph-loop/references/category-completeness.md +185 -0
  209. package/templates/skills/ralph-loop/references/compact-loop.md +1 -1
  210. package/templates/skills/ralph-loop/references/init-resume-recovery.md +127 -0
  211. package/templates/skills/ralph-loop/references/module-transition.md +151 -0
  212. package/templates/skills/ralph-loop/references/multi-module-queue.md +171 -0
  213. package/templates/skills/ralph-loop/references/parallel-execution.md +246 -0
  214. package/templates/skills/ralph-loop/references/task-transform-legacy.md +6 -9
  215. package/templates/skills/ralph-loop/references/team-orchestration.md +45 -3
  216. package/templates/skills/ralph-loop/steps/step-00-init.md +36 -109
  217. package/templates/skills/ralph-loop/steps/step-01-task.md +15 -163
  218. package/templates/skills/ralph-loop/steps/step-02-execute.md +8 -154
  219. package/templates/skills/ralph-loop/steps/step-04-check.md +20 -73
  220. package/templates/skills/review-code/references/owasp-api-top10.md +5 -5
  221. package/templates/skills/review-code/references/smartstack-conventions.md +568 -568
  222. package/templates/skills/validate-feature/references/api-smoke-tests.md +140 -0
  223. package/templates/skills/validate-feature/references/db-validation-checks.md +180 -0
  224. package/templates/skills/validate-feature/steps/step-01-compile.md +1 -3
  225. package/templates/skills/validate-feature/steps/step-04-api-smoke.md +34 -145
  226. package/templates/skills/validate-feature/steps/step-05-db-validation.md +74 -260
  227. package/templates/skills/workflow/SKILL.md +1 -1
  228. package/templates/skills/workflow/steps/step-00-init.md +57 -0
@@ -0,0 +1,140 @@
1
+ # API Smoke Test Procedure
2
+
3
+ > **Reference for:** step-04-api-smoke.md
4
+ > **Purpose:** Validate CRUD endpoints with real HTTP requests
5
+ > **Scope:** GET all, POST create, GET by ID, PUT update, DELETE, GET verify deleted
6
+
7
+ ---
8
+
9
+ ## Startup Sequence
10
+
11
+ ```bash
12
+ # Start API on test port
13
+ dotnet run --project {ApiProject} --urls "http://localhost:5099" > /tmp/api-smoke-output.log 2>&1 &
14
+ API_PID=$!
15
+
16
+ # Wait for readiness (with crash detection)
17
+ API_CRASHED=false
18
+ for i in $(seq 1 30); do
19
+ if ! kill -0 $API_PID 2>/dev/null; then
20
+ echo "API PROCESS CRASHED during startup"
21
+ cat /tmp/api-smoke-output.log 2>/dev/null
22
+ API_CRASHED=true
23
+ break
24
+ fi
25
+
26
+ HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5099/health 2>/dev/null)
27
+ if [ "$HTTP_CODE" != "000" ]; then
28
+ echo "API is ready (HTTP $HTTP_CODE)"
29
+ break
30
+ fi
31
+ sleep 1
32
+ done
33
+
34
+ # If API_CRASHED=true → Jump to section "Crash Classification" below
35
+ ```
36
+
37
+ ---
38
+
39
+ ## CRUD Test Sequence
40
+
41
+ ```bash
42
+ # Get auth token (optional)
43
+ TOKEN=$(curl -s -X POST http://localhost:5099/api/auth/login \
44
+ -H "Content-Type: application/json" \
45
+ -d '{"email":"admin@smartstack.io","password":"Admin123!"}' \
46
+ | jq -r '.token // .accessToken // empty')
47
+
48
+ # Headers
49
+ AUTH_HEADER="Authorization: Bearer $TOKEN"
50
+ TENANT_HEADER="X-Tenant-Id: 11111111-1111-1111-1111-111111111111"
51
+ CONTENT_TYPE="Content-Type: application/json"
52
+ ```
53
+
54
+ ### Test 1: GET All (expect 200)
55
+ ```bash
56
+ curl -s -w "\nHTTP %{http_code}" \
57
+ -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
58
+ http://localhost:5099/api/{entity_code}
59
+ ```
60
+
61
+ ### Test 2: POST Create (expect 201 or 200)
62
+ ```bash
63
+ CREATED=$(curl -s -X POST \
64
+ -H "$AUTH_HEADER" -H "$TENANT_HEADER" -H "$CONTENT_TYPE" \
65
+ -d '{"code":"smoke-test-01","name":"Smoke Test Entity"}' \
66
+ http://localhost:5099/api/{entity_code})
67
+ ENTITY_ID=$(echo "$CREATED" | jq -r '.id // .Id')
68
+ ```
69
+
70
+ ### Test 3: GET By ID (expect 200)
71
+ ```bash
72
+ curl -s -w "\nHTTP %{http_code}" \
73
+ -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
74
+ http://localhost:5099/api/{entity_code}/$ENTITY_ID
75
+ ```
76
+
77
+ ### Test 4: PUT Update (expect 200)
78
+ ```bash
79
+ curl -s -X PUT -w "\nHTTP %{http_code}" \
80
+ -H "$AUTH_HEADER" -H "$TENANT_HEADER" -H "$CONTENT_TYPE" \
81
+ -d '{"code":"smoke-test-01","name":"Updated Name"}' \
82
+ http://localhost:5099/api/{entity_code}/$ENTITY_ID
83
+ ```
84
+
85
+ ### Test 5: DELETE (expect 204)
86
+ ```bash
87
+ curl -s -X DELETE -w "\nHTTP %{http_code}" \
88
+ -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
89
+ http://localhost:5099/api/{entity_code}/$ENTITY_ID
90
+ ```
91
+
92
+ ### Test 6: GET Deleted (expect 404)
93
+ ```bash
94
+ curl -s -w "\nHTTP %{http_code}" \
95
+ -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
96
+ http://localhost:5099/api/{entity_code}/$ENTITY_ID
97
+ ```
98
+
99
+ ---
100
+
101
+ ## HTTP Error Classification
102
+
103
+ | Status | Error | Cause | Fix |
104
+ |--------|-------|-------|-----|
105
+ | 401 | Unauthorized | Auth not configured | Check JWT token generation |
106
+ | 403 | Forbidden | Permissions missing | Verify PermissionConfiguration seeding |
107
+ | 404 | Not Found | Route not registered | Check NavRoute attribute on controller |
108
+ | 500 | Internal Server Error | Unhandled exception | Check API startup logs |
109
+ | Connection refused | API won't start | Startup config error | Review appsettings.json |
110
+
111
+ ---
112
+
113
+ ## Crash Classification
114
+
115
+ If API process dies during startup, classify error from `/tmp/api-smoke-output.log`:
116
+
117
+ | Error Pattern | Category | Fix |
118
+ |---------------|----------|-----|
119
+ | `FileNotFoundException: Could not load file or assembly '{Name}, Version={V}'` | MISSING_PACKAGE | `dotnet add {ApiProject} package {Name} --version {Major.Minor.Patch}` |
120
+ | `FileNotFoundException: Could not load file or assembly '{Name}'` | MISSING_ASSEMBLY | Check .csproj references |
121
+ | `TypeLoadException: Could not load type '{Type}'` | VERSION_MISMATCH | Update package to correct version |
122
+ | `MissingMethodException` | VERSION_MISMATCH | Update package |
123
+ | `InvalidOperationException: Unable to resolve service for type '{Type}'` | MISSING_DI | Add DI registration in Program.cs |
124
+ | `SqlException` or connection errors | DATABASE_ERROR | Check appsettings.json connection string |
125
+
126
+ **For MISSING_PACKAGE:**
127
+ 1. Extract assembly name (text between single quotes)
128
+ 2. Extract version (Version=X.X.X.X segment)
129
+ 3. Map to NuGet: assembly name usually equals package name
130
+ 4. Output: `FIX: dotnet add {ApiProject} package {PackageName} --version {Major.Minor.Patch}`
131
+
132
+ ---
133
+
134
+ ## Cleanup
135
+
136
+ ```bash
137
+ kill $API_PID 2>/dev/null
138
+ wait $API_PID 2>/dev/null
139
+ rm -f /tmp/api-smoke-output.log
140
+ ```
@@ -0,0 +1,180 @@
1
+ # Database Validation Checks (SQL Server)
2
+
3
+ > **Reference for:** step-05-db-validation.md
4
+ > **Purpose:** Validate migrations, LINQ→SQL translation, multi-tenant isolation, seed data
5
+ > **Scope:** LocalDB availability, pending changes, migration application, integration tests, seed data config
6
+
7
+ ---
8
+
9
+ ## Check 1: LocalDB Availability
10
+
11
+ ```bash
12
+ sqllocaldb info MSSQLLocalDB
13
+ ```
14
+
15
+ **If NOT available:** Skip DB validation, set `DB_VALIDATION = SKIPPED`
16
+
17
+ ---
18
+
19
+ ## Check 2: Pending Model Changes
20
+
21
+ ```bash
22
+ dotnet ef migrations has-pending-model-changes \
23
+ --project "$INFRA_PROJECT" \
24
+ --startup-project "$API_PROJECT"
25
+ ```
26
+
27
+ | Exit Code | Meaning | Action |
28
+ |-----------|---------|--------|
29
+ | 0 | No pending | PASS — continue |
30
+ | Non-zero | Changes not in migration | **FAIL — create migration** |
31
+
32
+ **If FAIL:**
33
+ ```bash
34
+ dotnet ef migrations add {SuggestedName} \
35
+ --project {InfraProject} \
36
+ --startup-project {ApiProject} \
37
+ -o Persistence/Migrations
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Check 3: Apply Migrations on Temp DB
43
+
44
+ ```bash
45
+ DB_NAME="SmartStack_Validate_$(date +%s)"
46
+ CONN_STRING="Server=(localdb)\\MSSQLLocalDB;Database=$DB_NAME;Integrated Security=true;TrustServerCertificate=true;Connect Timeout=120;"
47
+
48
+ dotnet ef database update \
49
+ --connection "$CONN_STRING" \
50
+ --project "$INFRA_PROJECT" \
51
+ --startup-project "$API_PROJECT"
52
+ ```
53
+
54
+ **Common failures:**
55
+ - `Invalid column name` → migration ordering issue
56
+ - `There is already an object named` → duplicate migration
57
+ - `Cannot insert duplicate key` → seed data conflict
58
+
59
+ ---
60
+
61
+ ## Check 4: Integration Tests vs SQL Server
62
+
63
+ ```bash
64
+ TEST_PROJECT=$(ls tests/*Tests.Integration*/*.csproj 2>/dev/null | head -1)
65
+ dotnet test "$TEST_PROJECT" --no-build --verbosity normal
66
+ ```
67
+
68
+ **Validates:**
69
+ - LINQ → SQL translation on real SQL Server (not SQLite)
70
+ - Multi-tenant isolation (global query filters)
71
+ - Soft delete (IsDeleted filter)
72
+ - EF Core configuration (indexes, relationships, constraints)
73
+
74
+ **SQLite → SQL Server differences caught:**
75
+ - `LIKE` case sensitivity
76
+ - Date functions (`date('now')` vs `GETUTCDATE()`)
77
+ - String concatenation (`||` vs `+`)
78
+ - `LIMIT` vs `TOP`
79
+ - `AUTOINCREMENT` vs `IDENTITY`
80
+
81
+ ---
82
+
83
+ ## Check 5: Dev Seeding Configuration
84
+
85
+ ```bash
86
+ # Check appsettings for EnableDevSeeding
87
+ APPSETTINGS=$(ls appsettings.Development.json 2>/dev/null || ls appsettings.json 2>/dev/null)
88
+ PROGRAM_CS=$(find . -name "Program.cs" -path "*/Api/*" 2>/dev/null | head -1)
89
+
90
+ # Result: SEEDING_ENABLED = true/false
91
+ ```
92
+
93
+ | Config | Meaning | Action |
94
+ |--------|---------|--------|
95
+ | Program.cs override | PASS | Active in Development |
96
+ | appsettings EnableDevSeeding = true | PASS | Active |
97
+ | appsettings FALSE + no override | WARNING | DevDataSeeder won't run |
98
+
99
+ **Fix:** Add to Program.cs:
100
+ ```csharp
101
+ options.EnableDevSeeding = builder.Environment.IsDevelopment();
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Check 6: DefaultTenantId FK Validation
107
+
108
+ ```bash
109
+ SEED_CONSTANTS=$(find . -path "*/SeedConstants.cs" 2>/dev/null | head -1)
110
+ TENANT_GUID=$(grep -oP 'DefaultTenantId\s*=\s*Guid\.Parse\("([^"]+)"\)' "$SEED_CONSTANTS" | grep -oP '"[^"]+"' | tr -d '"')
111
+
112
+ # Verify GUID exists in database
113
+ sqlcmd -S "(localdb)\MSSQLLocalDB" -d "$DB_NAME" -Q "
114
+ SET NOCOUNT ON;
115
+ SELECT COUNT(*) FROM core.tenant_Tenants WHERE Id = '$TENANT_GUID'
116
+ "
117
+ ```
118
+
119
+ | Result | Status | Meaning |
120
+ |--------|--------|---------|
121
+ | COUNT > 0 | PASS | DefaultTenantId is valid |
122
+ | COUNT = 0 | FAIL | FK phantom: DevDataSeeder uses invalid TenantId → 500 errors |
123
+
124
+ **Fix:** Use a TenantId that is seeded by `InitializeSmartStackAsync()`
125
+
126
+ ---
127
+
128
+ ## Check 7: Seed Data Accessibility
129
+
130
+ ```bash
131
+ # Start API with temp DB
132
+ dotnet run --project "$API_PROJECT" \
133
+ --urls "http://localhost:5097" \
134
+ -- --ConnectionStrings:DefaultConnection="$CONN_STRING" &
135
+ SEED_PID=$!
136
+
137
+ # Verify seed data via API
138
+ TOKEN=$(curl -s -X POST http://localhost:5097/api/auth/login -H "Content-Type: application/json" -d '{"email":"admin@smartstack.io","password":"Admin123!"}' | jq -r '.accessToken')
139
+
140
+ NAV_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5097/api/platform/navigation/modules \
141
+ -H "Authorization: Bearer $TOKEN" \
142
+ -H "X-Tenant-Id: 11111111-1111-1111-1111-111111111111")
143
+ ```
144
+
145
+ | Status | Meaning |
146
+ |--------|---------|
147
+ | 200 | PASS — core seed data verified |
148
+ | 401 | WARNING — authentication issue, seed data check skipped |
149
+ | 404 | WARNING — API endpoint not available |
150
+
151
+ ---
152
+
153
+ ## Check 8: Cleanup
154
+
155
+ ```bash
156
+ # Drop temp database
157
+ sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "
158
+ IF DB_ID('$DB_NAME') IS NOT NULL
159
+ BEGIN
160
+ ALTER DATABASE [$DB_NAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
161
+ DROP DATABASE [$DB_NAME];
162
+ END
163
+ "
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Error Reference Table
169
+
170
+ | Error Pattern | Category | Fix |
171
+ |---------------|----------|-----|
172
+ | `Invalid column name '{Column}'` | Migration ordering | Reorder migration or split |
173
+ | `Cannot insert duplicate key` | Seed data conflict | Make seed data idempotent |
174
+ | `String or binary data would be truncated` | Column length | Increase MaxLength in EF config |
175
+ | `INSERT conflicted with FOREIGN KEY constraint` | Missing parent | Ensure parent entities seeded first |
176
+ | `NULL into column '{Column}'` | Missing default | Add default value or make nullable |
177
+ | `Login failed for user` | LocalDB auth | Run `sqllocaldb start MSSQLLocalDB` |
178
+ | `A network-related or instance-specific error` | LocalDB not running | Run `sqllocaldb start MSSQLLocalDB` |
179
+ | `DefaultTenantId does NOT exist in core.tenant_Tenants` | Phantom FK | Use valid TenantId from InitializeSmartStackAsync() |
180
+ | `EnableDevSeeding is FALSE` + empty tables | Seeding disabled | Add Program.cs override for Development |
@@ -18,10 +18,8 @@ ls *.sln 2>/dev/null || find . -maxdepth 2 -name "*.sln" -type f
18
18
  ### 2. Cleanup & Build
19
19
 
20
20
  ```bash
21
- # Cleanup corrupted EF Core design-time artifacts (Roslyn BuildHost bug on Windows)
22
- for d in src/*/bin?Debug; do [ -d "$d" ] && echo "Removing corrupted artifact: $d" && rm -rf "$d"; done
23
-
24
21
  dotnet build {SolutionFile} --verbosity minimal
22
+ # Note: WSL bin\Debug cleanup handled by PostToolUse hook (wsl-dotnet-cleanup.sh)
25
23
  ```
26
24
 
27
25
  ### 3. Evaluate result
@@ -8,122 +8,56 @@ prev_step: steps/step-03-integration-tests.md
8
8
 
9
9
  ## BLOCKING - All CRUD endpoints must respond correctly
10
10
 
11
+ See `references/api-smoke-tests.md` for complete startup, CRUD sequence, and error classification.
12
+
13
+ ---
14
+
15
+ ## Quick Procedure
16
+
11
17
  ### 1. Find the API project
12
18
 
13
19
  ```bash
14
- # Find the API project
15
20
  ls src/*Api*/*.csproj 2>/dev/null || ls *Api*/*.csproj 2>/dev/null
16
21
  ```
17
22
 
18
- ### 2. Start the API in the background (with output capture)
23
+ ### 2. Start API (see reference for crash detection)
19
24
 
20
25
  ```bash
21
- # Start the API on a test port, capturing stdout/stderr for error diagnosis
22
26
  dotnet run --project {ApiProject} --urls "http://localhost:5099" > /tmp/api-smoke-output.log 2>&1 &
23
27
  API_PID=$!
24
28
  ```
25
29
 
26
- ### 3. Wait for the API to be ready (with crash detection)
30
+ ### 3. CRUD Tests
27
31
 
28
32
  ```bash
29
- # Poll the health endpoint, checking for early process death
30
- API_CRASHED=false
31
- for i in $(seq 1 30); do
32
- # CRITICAL: Check if process is still alive FIRST
33
- if ! kill -0 $API_PID 2>/dev/null; then
34
- echo "API PROCESS CRASHED during startup"
35
- cat /tmp/api-smoke-output.log 2>/dev/null
36
- API_CRASHED=true
37
- break
38
- fi
39
-
40
- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5099/health 2>/dev/null)
41
- if [ "$HTTP_CODE" != "000" ]; then
42
- echo "API is ready (HTTP $HTTP_CODE)"
43
- break
44
- fi
45
- sleep 1
46
- done
33
+ # GET all (200)
34
+ # POST create (201)
35
+ # GET by ID (200)
36
+ # PUT update (200)
37
+ # DELETE (204)
38
+ # GET deleted (404) verify deletion
47
39
  ```
48
40
 
49
- **If `API_CRASHED=true`:** Skip directly to section 8b (crash classification). Do NOT attempt CRUD tests.
50
-
51
- ### 4. Authenticate (if required)
52
-
53
- ```bash
54
- # Try to login with default test credentials
55
- TOKEN=$(curl -s -X POST http://localhost:5099/api/auth/login \
56
- -H "Content-Type: application/json" \
57
- -d '{"email":"admin@smartstack.io","password":"Admin123!"}' \
58
- | jq -r '.token // .accessToken // empty')
59
- ```
41
+ See `references/api-smoke-tests.md` section "CRUD Test Sequence" for exact curl commands.
60
42
 
61
- If auth is not configured yet, tests may work without a token (depending on configuration).
43
+ ### 4. HTTP Error Handling
62
44
 
63
- ### 5. Test CRUD endpoints
45
+ | Status | Cause | Fix |
46
+ |--------|-------|-----|
47
+ | 401 | Auth not configured | Check JWT setup |
48
+ | 403 | Permissions missing | Verify PermissionConfiguration |
49
+ | 404 | Route not registered | Check NavRoute on controller |
50
+ | 500 | Unhandled exception | Check API logs |
51
+ | Connection refused | API won't start | Check appsettings.json |
64
52
 
65
- **Set common headers:**
66
- ```bash
67
- AUTH_HEADER="Authorization: Bearer $TOKEN"
68
- TENANT_HEADER="X-Tenant-Id: 11111111-1111-1111-1111-111111111111"
69
- CONTENT_TYPE="Content-Type: application/json"
70
- ```
53
+ ### 5. Crash Classification
71
54
 
72
- #### 5.1 GET all (expect 200)
73
- ```bash
74
- curl -s -w "\n%{http_code}" \
75
- -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
76
- http://localhost:5099/api/{entity_code}
77
- ```
78
- Expected: HTTP 200
55
+ If API crashes at startup:
56
+ - Classify error from `/tmp/api-smoke-output.log`
57
+ - See `references/api-smoke-tests.md` section "Crash Classification"
58
+ - Common: MISSING_PACKAGE, VERSION_MISMATCH, MISSING_DI, DATABASE_ERROR
79
59
 
80
- #### 5.2 POST create (expect 201 or 200)
81
- ```bash
82
- CREATED=$(curl -s -w "\n%{http_code}" \
83
- -X POST \
84
- -H "$AUTH_HEADER" -H "$TENANT_HEADER" -H "$CONTENT_TYPE" \
85
- -d '{"code":"smoke-test-01","name":"Smoke Test Entity"}' \
86
- http://localhost:5099/api/{entity_code})
87
- ```
88
- Expected: HTTP 201 or 200
89
- Extract the created entity ID from the response.
90
-
91
- #### 5.3 GET by ID (expect 200)
92
- ```bash
93
- curl -s -w "\n%{http_code}" \
94
- -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
95
- http://localhost:5099/api/{entity_code}/{created_id}
96
- ```
97
- Expected: HTTP 200 with the entity data
98
-
99
- #### 5.4 PUT update (expect 200)
100
- ```bash
101
- curl -s -w "\n%{http_code}" \
102
- -X PUT \
103
- -H "$AUTH_HEADER" -H "$TENANT_HEADER" -H "$CONTENT_TYPE" \
104
- -d '{"code":"smoke-test-01","name":"Updated Smoke Test"}' \
105
- http://localhost:5099/api/{entity_code}/{created_id}
106
- ```
107
- Expected: HTTP 200
108
-
109
- #### 5.5 DELETE (expect 204)
110
- ```bash
111
- curl -s -w "\n%{http_code}" \
112
- -X DELETE \
113
- -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
114
- http://localhost:5099/api/{entity_code}/{created_id}
115
- ```
116
- Expected: HTTP 204
117
-
118
- #### 5.6 GET deleted (expect 404)
119
- ```bash
120
- curl -s -w "\n%{http_code}" \
121
- -H "$AUTH_HEADER" -H "$TENANT_HEADER" \
122
- http://localhost:5099/api/{entity_code}/{created_id}
123
- ```
124
- Expected: HTTP 404 (confirms deletion)
125
-
126
- ### 6. Stop the API
60
+ ### 6. Stop API
127
61
 
128
62
  ```bash
129
63
  kill $API_PID 2>/dev/null
@@ -131,9 +65,9 @@ wait $API_PID 2>/dev/null
131
65
  rm -f /tmp/api-smoke-output.log
132
66
  ```
133
67
 
134
- ### 7. Evaluate results
68
+ ---
135
69
 
136
- Build a report:
70
+ ## Report
137
71
 
138
72
  ```markdown
139
73
  ## Feature Validation: {entity_name}
@@ -153,53 +87,8 @@ Build a report:
153
87
  ### Overall: {ALL_PASS or FAILURES_DETECTED}
154
88
  ```
155
89
 
156
- ### 8. Handle HTTP failures
157
-
158
- If any smoke test fails:
159
- - **401 Unauthorized** -> Auth not configured, check JWT setup
160
- - **403 Forbidden** -> Permissions not seeded, check PermissionConfiguration
161
- - **404 Not Found** -> Route not registered, check controller NavRoute
162
- - **500 Internal Server Error** -> Check API logs for exception details
163
- - **Connection refused** -> API didn't start, check startup configuration
164
-
165
- ### 8b. Handle startup crash (if API_CRASHED=true)
166
-
167
- If the API process died during startup, classify the error from the captured output:
168
-
169
- | Error Pattern in Output | Classification | Actionable Fix |
170
- |------------------------|----------------|----------------|
171
- | `FileNotFoundException: Could not load file or assembly '{Name}, Version={V}'` | **MISSING_PACKAGE** | `dotnet add {ApiProject} package {Name} --version {V.Major}.{V.Minor}.{V.Patch}` |
172
- | `FileNotFoundException: Could not load file or assembly '{Name}'` | **MISSING_ASSEMBLY** | Check .csproj references, ensure assembly is built |
173
- | `TypeLoadException: Could not load type '{Type}' from assembly '{Asm}'` | **VERSION_MISMATCH** | `dotnet add {ApiProject} package {Asm} --version {CorrectVersion}` |
174
- | `MissingMethodException` | **VERSION_MISMATCH** | Update package to matching version |
175
- | `InvalidOperationException: Unable to resolve service for type '{Type}'` | **MISSING_DI** | Add DI registration for `{Type}` in `DependencyInjection.cs` or `Program.cs` |
176
- | `SqlException` or connection errors | **DATABASE_ERROR** | Check connection string in `appsettings.json` |
177
-
178
- **For MISSING_PACKAGE errors:**
179
- 1. Extract assembly name: the text between single quotes after "file or assembly"
180
- 2. Extract version: the `Version=X.X.X.X` part (first 3 segments = NuGet version)
181
- 3. Map to NuGet package: assembly name usually equals package name
182
- 4. Output: `FIX: dotnet add {ApiProject} package {PackageName} --version {Major.Minor.Patch}`
183
- 5. **If assembly starts with `SmartStack.`**: this is a framework bug in SmartStack.csproj, not a client project issue
184
-
185
- **Report format for crashed API:**
186
- ```markdown
187
- ## Feature Validation: {entity_name}
188
-
189
- | Check | Result | Details |
190
- |-------|--------|---------|
191
- | Dependencies | {dependency_check_result} | |
192
- | Solution build | {build_result} | |
193
- | Unit tests | {unit_test_result} | {unit_test_count} passed |
194
- | Integration tests | {integration_test_result} | {integration_test_count} passed |
195
- | API startup | **CRASHED** | {classification}: {error_summary} |
196
-
197
- ### Crash Details
198
- **Classification:** {classification}
199
- **Error:** {first line of relevant error}
200
- **Fix:** `{fix_command}`
90
+ ---
201
91
 
202
- ### Overall: FAILURES_DETECTED (API startup crash)
203
- ```
92
+ ## NEXT STEP:
204
93
 
205
- Report all findings to the user with actionable next steps.
94
+ Proceed to `./step-05-db-validation.md`