@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
@@ -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,13 @@ 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
21
+ # Cleanup corrupted EF Core design-time artifacts (Roslyn BuildHost bug on Windows/WSL)
22
+ for d in src/*/bin?Debug bin?Debug; do [ -d "$d" ] && echo "Removing corrupted artifact: $d" && rm -rf "$d"; done
23
23
 
24
24
  dotnet build {SolutionFile} --verbosity minimal
25
+
26
+ # Post-build cleanup (WSL Roslyn recreates literal bin\Debug folders after each build)
27
+ for d in src/*/bin?Debug bin?Debug; do [ -d "$d" ] && rm -rf "$d"; done
25
28
  ```
26
29
 
27
30
  ### 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`