Commit 6f67c75
* feat: add validation layer — RuntimeCheck, CLI integration, MCP integration (#58, #59, #60)
Milestone 2 validation layer:
- Add RuntimeCheck (build binary, start app, probe HTTP routes) with full
test coverage including timeout, route probing, and process cleanup
- Add PostGenEngine for lightweight post-generation validation (go.mod,
templates, migrations) that skips compilation since sqlc hasn't run yet
- Add FullEngine/ValidateFull with RuntimeCheck for thorough validation
- Integrate --skip-validation flag into gen resource/view/schema and auth
- Add ValidationOutput structs to MCP server with structured JSON results
- Update MCP gen handlers to run validation explicitly (avoid double-run)
- Update help text and usage docs for --skip-validation
- Update existing tests with --skip-validation where compilation isn't expected
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address bot review comments on validation PR
- Fix gofmt formatting in mcp_server.go (CI failure)
- Handle os.Getwd() errors in MCP handlers instead of silently ignoring
- Fix Success/Message contradiction: Success reflects generation success,
Message adjusts when validation finds issues
- Pass context.Context through runMCPValidation for cancellation support
- Compose FullEngine from DefaultEngine to avoid check list drift
- Capture subprocess stdout/stderr in RuntimeCheck for better diagnostics
- Detect early process exit in waitForReady instead of waiting full timeout
- Run validation before success banner in gen.go to avoid contradictory output
- Fix misleading test comments about compilation (now structural validation)
- Document TOCTOU race in getFreePort
- Fix idiomatic bool check (decoded.Valid != false → decoded.Valid)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: prevent deadlock in RuntimeCheck on early process exit
When the subprocess exits before becoming ready, waitForReadyOrExit
drains the procDone channel. The deferred cleanup then tried to read
from the same channel, causing a deadlock. Track consumption state
to skip the redundant receive.
Also document the auth.go validation behavior difference vs gen.go.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address second round of review comments
- Rename WarnCount → WarningCount to match JSON tag (warning_count)
- Fix trimOutput to use rune-aware slicing for UTF-8 safety
- Use WithCheck() pattern in FullEngine instead of direct field mutation
- Add doc comments on Success field clarifying it reflects generation,
not validation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address third round of review comments
- Add early context cancellation guard in RuntimeCheck.Run() to avoid
misleading "build failed: " message when context is already cancelled
- Add TestGenSchema_WithValidation for test parity with resource/view
- Add TODO comment for context propagation in runPostGenValidation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: prevent panic when --skip-validation is the only arg
GenView and GenSchema checked len(args) before filtering out
--skip-validation, so `lvt gen view --skip-validation` would pass
the initial check then panic on args[0] after filtering left an
empty slice. Move flag parsing before positional arg validation.
Also improve RuntimeCheck error message on mid-execution context
cancellation to show "cancelled" instead of misleading timeout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove dead skipValidation assignment, improve MCP doc
Remove unnecessary `_ = skipValidation` blank assignments that were
left from development. Add doc note to runMCPValidation about using
validation.Validate() for full compilation checks.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: update MCP schema handler with validation, trim whitespace in output
- Add --skip-validation + explicit validation to registerGenSchemaTools,
matching the resource/view/auth MCP handler pattern. Previously the
schema handler would print validation text to stdout (corrupting MCP
JSON-RPC framing) and not return structured validation results.
- Add strings.TrimSpace to trimOutput for cleaner error messages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add explanatory comment on FullEngine construction pattern
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5b6c92f commit 6f67c75
11 files changed
Lines changed: 957 additions & 49 deletions
File tree
- commands
- internal/validation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
115 | 128 | | |
116 | 129 | | |
117 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
| 69 | + | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | | - | |
| 208 | + | |
| 209 | + | |
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | 135 | | |
| |||
140 | 143 | | |
141 | 144 | | |
142 | 145 | | |
| 146 | + | |
| 147 | + | |
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
| |||
204 | 209 | | |
205 | 210 | | |
206 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
207 | 218 | | |
208 | 219 | | |
209 | | - | |
210 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
211 | 227 | | |
212 | 228 | | |
213 | 229 | | |
| |||
226 | 242 | | |
227 | 243 | | |
228 | 244 | | |
229 | | - | |
| 245 | + | |
230 | 246 | | |
231 | 247 | | |
232 | 248 | | |
| |||
235 | 251 | | |
236 | 252 | | |
237 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
238 | 267 | | |
239 | 268 | | |
240 | 269 | | |
| |||
282 | 311 | | |
283 | 312 | | |
284 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
285 | 320 | | |
286 | 321 | | |
287 | | - | |
288 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
289 | 329 | | |
290 | 330 | | |
291 | 331 | | |
| |||
301 | 341 | | |
302 | 342 | | |
303 | 343 | | |
304 | | - | |
| 344 | + | |
305 | 345 | | |
306 | 346 | | |
307 | 347 | | |
| |||
310 | 350 | | |
311 | 351 | | |
312 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
313 | 366 | | |
314 | 367 | | |
315 | 368 | | |
| |||
376 | 429 | | |
377 | 430 | | |
378 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
379 | 438 | | |
380 | 439 | | |
381 | | - | |
382 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
383 | 447 | | |
384 | 448 | | |
385 | 449 | | |
| |||
392 | 456 | | |
393 | 457 | | |
394 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
395 | 475 | | |
396 | 476 | | |
397 | 477 | | |
| |||
0 commit comments