Commit 9d85c2e
claude
recommend: prewarm requests don't bump public toolkit count
The prewarm header was added to bypass per-IP rate limits + optional
force-refresh; it did NOT skip recordGeneration, so every prewarm call
bumped the public /api/toolkit-count counter. That's fine in principle
(the request was really served) but visually wrong: a 100-query
prewarm run would jump the homepage display from '400 toolkits built'
to '500' in a way that reads as inorganic.
Wrap each of the four recordGeneration call sites (L1 / L2 / legacy /
L3) with 'if !prewarm'. A valid prewarm token now warms the caches
without leaving a trace in toolkit_generations. The per-request log
line ('[recommend] L1 quick-match hit' etc.) still fires — ops
visibility preserved.
Scoped intentionally: the prewarm flag comes from a valid token + the
X-Stockyard-Prewarm header, so an unauthenticated scraper can't set
this header and have it quietly exempt them from the counter. Token
lives in STOCKYARD_PREWARM_TOKEN on Railway.
Verification:
- go build ./internal/site/...: clean
- go vet ./internal/site/...: clean
- Existing site tests: pass (no recommend-flow tests exist today;
the prewarm path is covered by the integration-style /api/recommend
call we'll make from the prewarm script post-deploy)
- Secret scan: 0 hits1 parent 6225749 commit 9d85c2e
1 file changed
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
415 | 417 | | |
416 | 418 | | |
417 | 419 | | |
| |||
428 | 430 | | |
429 | 431 | | |
430 | 432 | | |
431 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
432 | 436 | | |
433 | 437 | | |
434 | 438 | | |
| |||
450 | 454 | | |
451 | 455 | | |
452 | 456 | | |
453 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
454 | 460 | | |
455 | 461 | | |
456 | 462 | | |
| |||
610 | 616 | | |
611 | 617 | | |
612 | 618 | | |
613 | | - | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
614 | 622 | | |
615 | 623 | | |
616 | 624 | | |
| |||
0 commit comments