@atlashub/smartstack-cli 3.13.0 → 3.15.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 (54) hide show
  1. package/dist/index.js +26 -28
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +626 -141
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/agents/efcore/migration.md +15 -0
  7. package/templates/skills/apex/steps/step-04-validate.md +64 -5
  8. package/templates/skills/application/references/frontend-verification.md +20 -0
  9. package/templates/skills/application/steps/step-04-backend.md +17 -1
  10. package/templates/skills/application/steps/step-05-frontend.md +49 -23
  11. package/templates/skills/application/templates-seed.md +14 -4
  12. package/templates/skills/business-analyse/SKILL.md +3 -2
  13. package/templates/skills/business-analyse/_module-loop.md +5 -5
  14. package/templates/skills/business-analyse/html/ba-interactive.html +165 -0
  15. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +2 -0
  16. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +85 -0
  17. package/templates/skills/business-analyse/html/src/styles/05-modules.css +65 -0
  18. package/templates/skills/business-analyse/html/src/template.html +13 -0
  19. package/templates/skills/business-analyse/questionnaire.md +1 -1
  20. package/templates/skills/business-analyse/references/cache-warming-strategy.md +11 -23
  21. package/templates/skills/business-analyse/references/cadrage-pre-analysis.md +112 -0
  22. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +6 -1
  23. package/templates/skills/business-analyse/references/deploy-data-build.md +1 -1
  24. package/templates/skills/business-analyse/references/html-data-mapping.md +1 -1
  25. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  26. package/templates/skills/business-analyse/references/spec-auto-inference.md +1 -1
  27. package/templates/skills/business-analyse/schemas/application-schema.json +38 -1
  28. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +2 -1
  29. package/templates/skills/business-analyse/steps/step-00-init.md +18 -22
  30. package/templates/skills/business-analyse/steps/step-01-cadrage.md +383 -128
  31. package/templates/skills/business-analyse/steps/step-02-decomposition.md +42 -16
  32. package/templates/skills/business-analyse/steps/step-03a-data.md +5 -31
  33. package/templates/skills/business-analyse/steps/step-03a1-setup.md +41 -2
  34. package/templates/skills/business-analyse/steps/step-03b-ui.md +20 -11
  35. package/templates/skills/business-analyse/steps/step-03d-validate.md +6 -6
  36. package/templates/skills/business-analyse/steps/step-04-consolidation.md +5 -31
  37. package/templates/skills/business-analyse/steps/step-04c-decide.md +1 -1
  38. package/templates/skills/business-analyse/steps/step-05a-handoff.md +1 -1
  39. package/templates/skills/business-analyse/steps/step-05b-deploy.md +3 -3
  40. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +1 -1
  41. package/templates/skills/business-analyse/templates/tpl-frd.md +1 -1
  42. package/templates/skills/efcore/steps/shared/step-00-init.md +55 -0
  43. package/templates/skills/ralph-loop/SKILL.md +1 -0
  44. package/templates/skills/ralph-loop/references/category-rules.md +131 -27
  45. package/templates/skills/ralph-loop/references/compact-loop.md +61 -3
  46. package/templates/skills/ralph-loop/references/core-seed-data.md +251 -5
  47. package/templates/skills/ralph-loop/references/error-classification.md +143 -0
  48. package/templates/skills/ralph-loop/steps/step-05-report.md +54 -0
  49. package/templates/skills/review-code/references/smartstack-conventions.md +16 -0
  50. package/templates/skills/validate-feature/SKILL.md +11 -1
  51. package/templates/skills/validate-feature/steps/step-00-dependencies.md +121 -0
  52. package/templates/skills/validate-feature/steps/step-04-api-smoke.md +61 -13
  53. package/templates/skills/validate-feature/steps/step-05-db-validation.md +250 -0
  54. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +0 -87
@@ -0,0 +1,143 @@
1
+ # Error Classification Reference
2
+
3
+ > **Loaded by:** compact-loop.md (build failure analysis) and category-rules.md (validation section)
4
+ > **Purpose:** Classify build and runtime errors to apply the correct fix strategy.
5
+ > **Key insight:** Not all errors are code errors. Package/config errors require different fixes than code errors.
6
+
7
+ ---
8
+
9
+ ## Error Categories
10
+
11
+ ### Category A: Missing NuGet Package (FIX = `dotnet add package`)
12
+
13
+ > **These errors CANNOT be fixed by editing source code. Do NOT waste iterations trying.**
14
+
15
+ | Error Pattern | Example | Fix |
16
+ |--------------|---------|-----|
17
+ | `FileNotFoundException: Could not load file or assembly '{Name}, Version={V}'` | `Could not load file or assembly 'Microsoft.Extensions.Http.Resilience, Version=10.2.0.0'` | `dotnet add package {Name} --version {V.Major}.{V.Minor}.{V.Patch}` |
18
+ | `error CS0246: The type or namespace name '{Type}' could not be found` (after restore) | `The type or namespace name 'Polly' could not be found` | `dotnet add package {PackageName}` |
19
+ | `error NU1101: Unable to find package {Name}` | Package source misconfigured | Check `nuget.config` sources |
20
+
21
+ **Detection heuristic:** If `dotnet build` fails with CS0246 and the missing type is NOT in any project file (grep across `src/`), it is a missing package, not a missing `using` statement.
22
+
23
+ **Fix procedure:**
24
+ 1. Extract package name from error message
25
+ 2. Run `dotnet add {TargetProject} package {PackageName}`
26
+ 3. Run `dotnet restore`
27
+ 4. Rebuild -- if still failing, the version may need to be pinned
28
+
29
+ ---
30
+
31
+ ### Category B: Version Mismatch (FIX = update package version)
32
+
33
+ > **These errors CANNOT be fixed by editing source code.**
34
+
35
+ | Error Pattern | Example | Fix |
36
+ |--------------|---------|-----|
37
+ | `TypeLoadException: Could not load type '{Type}' from assembly '{Asm}'` | Type exists in different version | `dotnet add package {Asm} --version {CorrectVersion}` |
38
+ | `MissingMethodException: Method not found: '{Method}'` | Method signature changed between versions | Update to version that has the method |
39
+ | `NU1605: Detected package downgrade` | Version conflict in dependency tree | Align all references to same version |
40
+ | `FileLoadException: Could not load file or assembly '{Name}'. The located assembly's manifest definition does not match the assembly reference.` | Wrong version loaded | Pin correct version in .csproj |
41
+
42
+ **Fix procedure:**
43
+ 1. Identify the assembly/package name
44
+ 2. Run `dotnet list package --include-transitive` to see actual resolved version
45
+ 3. If conflict: add explicit `<PackageReference>` with correct version
46
+ 4. Rebuild
47
+
48
+ ---
49
+
50
+ ### Category C: Missing DI Registration (FIX = edit DI configuration)
51
+
52
+ > **These errors require editing `DependencyInjection.cs` or `Program.cs`, NOT the service/interface code.**
53
+
54
+ | Error Pattern | Example | Fix |
55
+ |--------------|---------|-----|
56
+ | `InvalidOperationException: Unable to resolve service for type '{Interface}'` | Missing `services.AddScoped<IFoo, Foo>()` | Add DI registration |
57
+ | `InvalidOperationException: No service for type '{Type}' has been registered` | Same as above | Same |
58
+ | `InvalidOperationException: Unable to resolve service for type '{Type}' while attempting to activate '{Consumer}'` | Consumer's dependency not registered | Register the missing dependency |
59
+
60
+ **Fix procedure:**
61
+ 1. Extract the interface/type name from error
62
+ 2. Find the implementation class (grep for `class.*: {Interface}`)
63
+ 3. Add `services.AddScoped<{Interface}, {Implementation}>()` to appropriate DI file
64
+ 4. Rebuild
65
+
66
+ ---
67
+
68
+ ### Category D: Database/Migration (FIX = run migration commands)
69
+
70
+ | Error Pattern | Example | Fix |
71
+ |--------------|---------|-----|
72
+ | `SqlException: Invalid object name '{TableName}'` | Table does not exist | `dotnet ef database update` |
73
+ | `SqlException: Invalid column name '{Column}'` | Column not in schema | Create and apply migration |
74
+ | `RelationalEventId.PendingModelChangesWarning` | Model changed, no migration | `dotnet ef migrations add {Name}` |
75
+
76
+ ---
77
+
78
+ ### Category E: Configuration (FIX = edit appsettings.json)
79
+
80
+ | Error Pattern | Example | Fix |
81
+ |--------------|---------|-----|
82
+ | `InvalidOperationException: The ConnectionString property has not been initialized` | Missing connection string | Add to `appsettings.json` |
83
+ | `ArgumentNullException: Value cannot be null. (Parameter 'connectionString')` | Same | Same |
84
+ | `OptionsValidationException: Validation failed for '{Section}'` | Missing required config section | Add section to `appsettings.json` |
85
+
86
+ ---
87
+
88
+ ### Category F: Code Error (FIX = edit source code)
89
+
90
+ > **Only this category should trigger code editing in ralph-loop iterations.**
91
+
92
+ | Error Pattern | Example | Fix |
93
+ |--------------|---------|-----|
94
+ | `error CS0246` + type IS in a project file | Missing `using` statement | Add `using {Namespace};` |
95
+ | `error CS1061` | Method does not exist on type | Fix method call or add method |
96
+ | `error CS0103` | Name does not exist in current context | Fix variable/method reference |
97
+ | `error CS0029` | Cannot implicitly convert type | Fix type mismatch |
98
+ | Test assertion failures | `Assert.Equal` fails | Fix source code (not tests) |
99
+
100
+ ---
101
+
102
+ ## Decision Tree
103
+
104
+ When a build or runtime error occurs, follow this tree:
105
+
106
+ ```
107
+ BUILD/RUNTIME ERROR
108
+ |
109
+ +-- Contains "Could not load file or assembly" ?
110
+ | YES -> Category A or B (NEVER edit source code)
111
+ | Extract package name -> dotnet add package -> rebuild
112
+ |
113
+ +-- Contains "Unable to resolve service" ?
114
+ | YES -> Category C (edit DI config ONLY)
115
+ | Find implementation -> add registration -> rebuild
116
+ |
117
+ +-- Contains "SqlException" or "Invalid object name" ?
118
+ | YES -> Category D (run migrations)
119
+ | dotnet ef migrations add / database update
120
+ |
121
+ +-- Contains "ConnectionString" or "OptionsValidation" ?
122
+ | YES -> Category E (edit config files)
123
+ |
124
+ +-- error CS#### (C# compiler error) ?
125
+ | YES -> Is the missing type in ANY project file?
126
+ | NO -> Category A (missing package)
127
+ | YES -> Category F (fix source code)
128
+ |
129
+ +-- Test failure (Assert/Expected) ?
130
+ YES -> Category F (fix source code, NOT tests)
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Ralph-Loop Integration Rules
136
+
137
+ 1. **Before ANY code fix attempt:** Classify the error using the decision tree above
138
+ 2. **Categories A, B:** Run package commands IMMEDIATELY. Do NOT count as a "fix iteration"
139
+ 3. **Category C:** Edit DI file only. One targeted fix, rebuild, verify
140
+ 4. **Category D:** Run migration commands. Do NOT edit code
141
+ 5. **Category E:** Edit config file only
142
+ 6. **Category F:** Normal ralph-loop code fix iteration
143
+ 7. **If 2+ consecutive iterations fail on same error after code fixes -> re-classify** (likely wrong category)
@@ -70,6 +70,60 @@ if [ -d "$TEST_PROJECT" ]; then
70
70
  fi
71
71
  ```
72
72
 
73
+ ### 1e. Final DB Validation (if infrastructure/migration tasks were executed)
74
+
75
+ ```bash
76
+ INFRA_PROJECT=$(ls src/*Infrastructure*/*.csproj 2>/dev/null | head -1)
77
+ API_PROJECT=$(ls src/*Api*/*.csproj 2>/dev/null | head -1)
78
+
79
+ if [ -n "$INFRA_PROJECT" ] && [ -n "$API_PROJECT" ]; then
80
+ echo "FINAL DB VALIDATION: Applying all migrations on fresh SQL Server LocalDB..."
81
+
82
+ # 1. Check no pending model changes
83
+ dotnet ef migrations has-pending-model-changes \
84
+ --project "$INFRA_PROJECT" \
85
+ --startup-project "$API_PROJECT"
86
+ PENDING_RESULT=$?
87
+
88
+ # 2. Apply all migrations on temp database
89
+ DB_NAME="SmartStack_FinalCheck_$(date +%s)"
90
+ CONN_STRING="Server=(localdb)\\MSSQLLocalDB;Database=$DB_NAME;Integrated Security=true;TrustServerCertificate=true;Connect Timeout=120;"
91
+ dotnet ef database update \
92
+ --connection "$CONN_STRING" \
93
+ --project "$INFRA_PROJECT" \
94
+ --startup-project "$API_PROJECT"
95
+ MIGRATION_RESULT=$?
96
+
97
+ # 3. Run integration tests against real SQL Server
98
+ INT_TEST_PROJECT=$(ls tests/*Tests.Integration*/*.csproj 2>/dev/null | head -1)
99
+ INT_TEST_RESULT=0
100
+ if [ -n "$INT_TEST_PROJECT" ]; then
101
+ dotnet test "$INT_TEST_PROJECT" --no-build --verbosity minimal
102
+ INT_TEST_RESULT=$?
103
+ fi
104
+
105
+ # 4. Cleanup
106
+ sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "IF DB_ID('$DB_NAME') IS NOT NULL BEGIN ALTER DATABASE [$DB_NAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [$DB_NAME]; END" 2>/dev/null
107
+
108
+ # Record results
109
+ DB_VALIDATION="PASS"
110
+ [ $PENDING_RESULT -ne 0 ] && DB_VALIDATION="FAIL (pending model changes)"
111
+ [ $MIGRATION_RESULT -ne 0 ] && DB_VALIDATION="FAIL (migration apply failed)"
112
+ [ $INT_TEST_RESULT -ne 0 ] && DB_VALIDATION="FAIL (integration tests failed on SQL Server)"
113
+ fi
114
+ ```
115
+
116
+ Include DB validation results in report section:
117
+ ```markdown
118
+ ## DB Validation (SQL Server LocalDB)
119
+ | Check | Result |
120
+ |-------|--------|
121
+ | Pending model changes | {PENDING_RESULT == 0 ? "PASS" : "FAIL"} |
122
+ | Migrations apply cleanly | {MIGRATION_RESULT == 0 ? "PASS" : "FAIL"} |
123
+ | Integration tests (real SQL Server) | {INT_TEST_RESULT == 0 ? "PASS" : "N/A"} |
124
+ | Overall | {DB_VALIDATION} |
125
+ ```
126
+
73
127
  ## 2. Generate Report
74
128
 
75
129
  Write to `.ralph/reports/{feature-slug}.md`:
@@ -291,6 +291,22 @@ builder.ToTable("auth_users", SchemaConstants.Core);
291
291
  | `doc_` | Documents | doc_files, doc_versions |
292
292
  | `tkt_` | Tickets/Support | tkt_tickets, tkt_comments |
293
293
 
294
+ **Custom Application Prefixes:**
295
+
296
+ Business applications define their own table prefix during `/business-analyse` cadrage phase.
297
+ Format: `{2-5 lowercase letters}_` — stored in `feature.json` → `metadata.tablePrefix`.
298
+
299
+ | Application | Prefix | Examples |
300
+ |-------------|--------|----------|
301
+ | Human Resources | `rh_` | rh_Employees, rh_Contracts |
302
+ | Finance | `fi_` | fi_Invoices, fi_Payments |
303
+ | CRM | `crm_` | crm_Contacts, crm_Opportunities |
304
+
305
+ Rules:
306
+ - Must not collide with platform prefixes
307
+ - Registered in MCP config via `conventions.customTablePrefixes`
308
+ - All entities in the same application share the same prefix
309
+
294
310
  **Schemas:**
295
311
  - `core` (SchemaConstants.Core): SmartStack platform tables
296
312
  - `extensions` (SchemaConstants.Extensions): Client-specific tables
@@ -11,10 +11,12 @@ tags: [testing, validation, smoke-test, integration]
11
11
  ## PURPOSE
12
12
 
13
13
  Validates that a scaffolded SmartStack feature **actually works** by running:
14
+ 0. Dependency pre-flight check (restore, transitive deps, quick startup test)
14
15
  1. Compilation check (`dotnet build`)
15
16
  2. Unit tests (`dotnet test`)
16
17
  3. Integration tests (`dotnet test --filter`)
17
18
  4. API smoke test (start API, hit CRUD endpoints, verify responses)
19
+ 5. DB validation (SQL Server: migrations, seed data, tenant isolation, LINQ→SQL)
18
20
 
19
21
  ## WHEN TO USE
20
22
 
@@ -50,14 +52,16 @@ Validates that a scaffolded SmartStack feature **actually works** by running:
50
52
 
51
53
  ## EXECUTION
52
54
 
53
- This skill follows a 4-step sequential workflow:
55
+ This skill follows a 6-step sequential workflow:
54
56
 
55
57
  | Step | File | Description | Blocking |
56
58
  |------|------|-------------|----------|
59
+ | 0 | `steps/step-00-dependencies.md` | Pre-flight dependency check (restore, runtime assembly validation) | YES |
57
60
  | 1 | `steps/step-01-compile.md` | Build the full solution | YES |
58
61
  | 2 | `steps/step-02-unit-tests.md` | Run unit tests | YES |
59
62
  | 3 | `steps/step-03-integration-tests.md` | Run integration tests | YES |
60
63
  | 4 | `steps/step-04-api-smoke.md` | Start API and test CRUD endpoints | YES |
64
+ | 5 | `steps/step-05-db-validation.md` | SQL Server validation (migrations, seed data, tenant isolation, LINQ→SQL) | YES |
61
65
 
62
66
  Each step must PASS before proceeding to the next.
63
67
 
@@ -78,6 +82,9 @@ A validation report showing pass/fail for each check:
78
82
  | API smoke: GET /api/{entity}/{id} | PASS (200) |
79
83
  | API smoke: PUT /api/{entity}/{id} | PASS (200) |
80
84
  | API smoke: DELETE /api/{entity}/{id} | PASS (204) |
85
+ | DB: Migrations apply (SQL Server) | PASS |
86
+ | DB: Integration tests (SQL Server) | PASS |
87
+ | DB: Seed data accessible | PASS |
81
88
 
82
89
  Result: ALL CHECKS PASSED
83
90
  ```
@@ -87,5 +94,8 @@ Result: ALL CHECKS PASSED
87
94
  - All unit tests pass
88
95
  - All integration tests pass
89
96
  - API smoke tests return expected HTTP status codes (200, 201, 204)
97
+ - Migrations apply cleanly on SQL Server LocalDB
98
+ - Integration tests pass against real SQL Server (LINQ→SQL, tenant isolation)
99
+ - Seed data is accessible via API endpoints
90
100
  - Validation report displayed with per-check results
91
101
  </success_criteria>
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: step-00-dependencies
3
+ description: Pre-flight dependency check - verify NuGet packages and runtime assembly resolution
4
+ next_step: steps/step-01-compile.md
5
+ ---
6
+
7
+ # Step 0: Dependency Pre-Flight Check
8
+
9
+ ## BLOCKING - Must pass before proceeding to compilation
10
+
11
+ ### 1. Locate the solution file
12
+
13
+ ```bash
14
+ ls *.sln 2>/dev/null || find . -maxdepth 2 -name "*.sln" -type f
15
+ ```
16
+
17
+ Store as `{solution_file}`.
18
+
19
+ ### 2. Restore packages with diagnostic output
20
+
21
+ ```bash
22
+ dotnet restore {SolutionFile} --verbosity normal 2>&1
23
+ ```
24
+
25
+ **Parse the output for these NuGet warnings:**
26
+
27
+ | Warning Code | Meaning | Action |
28
+ |-------------|---------|--------|
29
+ | `NU1603` | Package version resolved to different version than requested | Version mismatch -- verify package versions in .csproj |
30
+ | `NU1605` | Downgrade detected | Package version conflict -- update to consistent version |
31
+ | `NU1608` | Package version outside dependency constraint | Incompatible dependency versions |
32
+ | `NU1701` | Package restored using fallback target framework | Potential runtime incompatibility |
33
+ | `NU1902` | Package version range could not be satisfied | Missing package source |
34
+
35
+ **If ANY NU1603/NU1605/NU1608 warnings are found:**
36
+ - List each warning with the affected package name and versions
37
+ - Suggest fix command: `dotnet add {ProjectFile} package {PackageName} --version {CorrectVersion}`
38
+ - This is a WARNING (proceed with caution, may cause runtime errors)
39
+
40
+ ### 3. Quick startup smoke test (runtime assembly validation)
41
+
42
+ > **CRITICAL:** This step catches errors that `dotnet build` alone misses.
43
+ > A successful build does NOT guarantee all assemblies are resolvable at runtime.
44
+ > Example: `FileNotFoundException: Could not load file or assembly 'X'` only appears at runtime.
45
+
46
+ ```bash
47
+ # Find the API project
48
+ API_PROJECT=$(ls src/*Api*/*.csproj 2>/dev/null | head -1)
49
+
50
+ if [ -n "$API_PROJECT" ]; then
51
+ # Build first (quick, no restore)
52
+ dotnet build "$API_PROJECT" --no-restore --verbosity quiet 2>&1
53
+
54
+ # Start the API and capture output
55
+ dotnet run --project "$API_PROJECT" --urls "http://localhost:5098" > /tmp/ss-dep-check.log 2>&1 &
56
+ STARTUP_PID=$!
57
+
58
+ # Wait up to 10 seconds for either: process exits (crash) or health responds (success)
59
+ STARTUP_OK=false
60
+ for i in $(seq 1 10); do
61
+ # Check if process is still alive
62
+ if ! kill -0 $STARTUP_PID 2>/dev/null; then
63
+ # Process died - read the output for error classification
64
+ echo "API STARTUP CRASH DETECTED"
65
+ cat /tmp/ss-dep-check.log
66
+ break
67
+ fi
68
+
69
+ # Check if health endpoint responds
70
+ HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5098/health 2>/dev/null)
71
+ if [ "$HTTP_CODE" != "000" ]; then
72
+ STARTUP_OK=true
73
+ break
74
+ fi
75
+ sleep 1
76
+ done
77
+
78
+ # Cleanup
79
+ kill $STARTUP_PID 2>/dev/null
80
+ wait $STARTUP_PID 2>/dev/null
81
+ rm -f /tmp/ss-dep-check.log
82
+ fi
83
+ ```
84
+
85
+ ### 4. Classify startup errors (if crash detected)
86
+
87
+ If the API process crashed, read the output and classify:
88
+
89
+ | Error Pattern | Classification | Fix Command |
90
+ |--------------|----------------|-------------|
91
+ | `FileNotFoundException: Could not load file or assembly '{Name}, Version={V}'` | **MISSING_PACKAGE** | `dotnet add {ApiProject} package {Name} --version {V.Major}.{V.Minor}.{V.Patch}` |
92
+ | `FileNotFoundException: Could not load file or assembly '{Name}'` (no version) | **MISSING_ASSEMBLY** | Check .csproj references and `PrivateAssets` settings |
93
+ | `TypeLoadException: Could not load type '{Type}' from assembly '{Asm}'` | **VERSION_MISMATCH** | `dotnet add {ApiProject} package {Asm} --version {CorrectVersion}` |
94
+ | `MissingMethodException: Method not found: '{Method}'` | **VERSION_MISMATCH** | Update package to matching version |
95
+ | `InvalidOperationException: Unable to resolve service for type '{Type}'` | **MISSING_DI** | Add `services.AddScoped<{Interface}, {Implementation}>()` in DI setup |
96
+ | `InvalidOperationException: The ConnectionString property has not been initialized` | **MISSING_CONFIG** | Add connection string to `appsettings.json` |
97
+
98
+ **For MISSING_PACKAGE specifically:**
99
+ 1. Extract the assembly name from the error (text between quotes after "file or assembly")
100
+ 2. The NuGet package name is usually identical to the assembly name (e.g., `Microsoft.Extensions.Http.Resilience`)
101
+ 3. Extract the version: `Version=X.X.X.X` -> take first 3 segments as NuGet version
102
+ 4. Provide exact fix: `dotnet add {ApiProject} package {PackageName} --version {Major.Minor.Patch}`
103
+ 5. **If assembly starts with `SmartStack.`**: this is a framework bug in SmartStack.csproj, not a client project issue
104
+
105
+ ### 5. Evaluate result
106
+
107
+ | Scenario | Action |
108
+ |----------|--------|
109
+ | No warnings, startup OK | PASS -> proceed to step 1 (compile) |
110
+ | Warnings only, startup OK | WARNING -> display warnings, proceed to step 1 |
111
+ | Startup crash with classified error | **FAIL** -> display classification + fix command, **STOP** |
112
+ | Startup crash with unclassified error | **FAIL** -> display full output, **STOP** for investigation |
113
+
114
+ ### 6. Store state
115
+
116
+ ```
117
+ {dependency_check_result} = PASS | WARNING | FAIL
118
+ {dependency_warnings} = list of warnings (if any)
119
+ {startup_error_class} = classification (if crash detected)
120
+ {startup_fix_command} = suggested fix command (if crash detected)
121
+ ```
@@ -15,32 +15,38 @@ prev_step: steps/step-03-integration-tests.md
15
15
  ls src/*Api*/*.csproj 2>/dev/null || ls *Api*/*.csproj 2>/dev/null
16
16
  ```
17
17
 
18
- ### 2. Start the API in the background
18
+ ### 2. Start the API in the background (with output capture)
19
19
 
20
20
  ```bash
21
- # Start the API on a test port
22
- dotnet run --project {ApiProject} --urls "http://localhost:5099" &
21
+ # Start the API on a test port, capturing stdout/stderr for error diagnosis
22
+ dotnet run --project {ApiProject} --urls "http://localhost:5099" > /tmp/api-smoke-output.log 2>&1 &
23
23
  API_PID=$!
24
24
  ```
25
25
 
26
- ### 3. Wait for the API to be ready
26
+ ### 3. Wait for the API to be ready (with crash detection)
27
27
 
28
28
  ```bash
29
- # Poll the health endpoint (or root) until it responds
29
+ # Poll the health endpoint, checking for early process death
30
+ API_CRASHED=false
30
31
  for i in $(seq 1 30); do
31
- curl -s -o /dev/null -w "%{http_code}" http://localhost:5099/health 2>/dev/null
32
- if [ $? -eq 0 ]; then
33
- echo "API is ready"
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)"
34
43
  break
35
44
  fi
36
45
  sleep 1
37
46
  done
38
47
  ```
39
48
 
40
- If no `/health` endpoint exists, try:
41
- ```bash
42
- curl -s -o /dev/null -w "%{http_code}" http://localhost:5099/api/{entity_code}
43
- ```
49
+ **If `API_CRASHED=true`:** Skip directly to section 8b (crash classification). Do NOT attempt CRUD tests.
44
50
 
45
51
  ### 4. Authenticate (if required)
46
52
 
@@ -121,6 +127,8 @@ Expected: HTTP 404 (confirms deletion)
121
127
 
122
128
  ```bash
123
129
  kill $API_PID 2>/dev/null
130
+ wait $API_PID 2>/dev/null
131
+ rm -f /tmp/api-smoke-output.log
124
132
  ```
125
133
 
126
134
  ### 7. Evaluate results
@@ -145,7 +153,7 @@ Build a report:
145
153
  ### Overall: {ALL_PASS or FAILURES_DETECTED}
146
154
  ```
147
155
 
148
- ### 8. Handle failures
156
+ ### 8. Handle HTTP failures
149
157
 
150
158
  If any smoke test fails:
151
159
  - **401 Unauthorized** -> Auth not configured, check JWT setup
@@ -154,4 +162,44 @@ If any smoke test fails:
154
162
  - **500 Internal Server Error** -> Check API logs for exception details
155
163
  - **Connection refused** -> API didn't start, check startup configuration
156
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}`
201
+
202
+ ### Overall: FAILURES_DETECTED (API startup crash)
203
+ ```
204
+
157
205
  Report all findings to the user with actionable next steps.