DocFast session 138: usage/me endpoint, shutdown flush fix

This commit is contained in:
Hoid 2026-03-07 08:06:45 +01:00
parent a85cf6685f
commit a8de348e0a
2 changed files with 23 additions and 2 deletions

View file

@ -1,5 +1,26 @@
# Session Log
## Session 138 — 2026-03-07 07:00 UTC (Saturday Morning)
- **Production:** v0.5.1 ✅ healthy, 2 replicas, 0 restarts, ~9d uptime
- **Staging:** v0.5.2 ✅ commit dd337d3 (48+ commits ahead of prod)
- **K8s cluster:** All 3 nodes Ready
- **Support:** Zero tickets
- **Completed:**
1. **User-facing usage endpoint (TDD)** — Added `GET /v1/usage/me` so Pro customers can check their own PDF usage. Returns `{used, limit, plan, month}`. Added `getUsageForKey()` export to usage middleware. 5 TDD tests. Commit dd337d3.
2. **Shutdown usage flush race fix (TDD)** — Removed fire-and-forget SIGTERM/SIGINT handlers from `usage.ts` (race with pool.end()). Shutdown in `index.ts` now `await flushDirtyEntries()` before closing browser/DB pools. 2 TDD tests. Commit 2b4fa0c.
3. **Full infrastructure health check** — All 3 K8s nodes Ready, both prod replicas healthy (0 restarts, ~9d uptime), DB connected (PostgreSQL 17.4), browser pool 15/15.
4. **Codebase audit** — Reviewed graceful shutdown, signal handling, module-level side effects. Found and fixed the shutdown race. Verified examples page, landing page, OpenAPI spec.
- **Total tests:** 527 (all passing, 0 errors), 40 test files
- **Open bugs:** ZERO 🎉
- **CI runner:** Still absent. Managed by Cloonar — needs investor action. Latest commits not built into staging image.
- **Investor test:**
1. Would a stranger trust this with money? Yes ✅
2. Pod crash = data loss? No — CNPG WAL archiving + MinIO ✅ (and usage now properly flushed on shutdown)
3. Free tier abuse? No — removed, demo rate-limited ✅
4. Pro key recovery? Yes — with DB fallback across pods ✅
5. Every feature works? Yes ✅
- **Recommendation:** Staging v0.5.2 production-ready. 48+ commits ahead with 527 tests. Awaiting investor approval for production tag + CI runner restoration.
## Session 137 — 2026-03-06 19:00 UTC (Friday Evening)
- **Production:** v0.5.1 ✅ healthy, 2 replicas, 0 restarts, ~8d uptime
- **Staging:** v0.5.2 ✅ commit b964b98 (46+ commits ahead of prod)