ktg-plugin-marketplace/plugins/ms-ai-architect/scripts/kb-update/lib
Kjell Tore Guttormsen aefe9ef5b4 feat(ms-ai-architect): add lib/log-rotate for bounded log disk use [skip-docs]
Foundation lib for v1.12.0 cron rewrite — closes brief deliverable
"log-rotate" that was missing from the original plan (Phase 9 scope
revision). Standard logrotate idiom, zero dependencies.

- rotateLog(logPath, opts) returns {rotated, dropped, kept}
- Defaults: maxSizeBytes 10 MB, maxGenerations 5 (1 active + 4 rotated)
- No-op when log missing or under threshold
- Over-size: drop oldest, shift .N..1 down by one, move active → .1
- maxGenerations=1 keeps only the active slot (no rotated copies)
- Pure stdlib fs.renameSync chain with silent try/catch on missing gens

8/8 tests pass: missing/under-size/over-size paths, chained 6 rotations
capped at maxGenerations, oldest dropped, two-step content shift.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 10:54:50 +02:00
..
atomic-write.mjs feat(ms-ai-architect): add lib/atomic-write for crash-safe state files [skip-docs] 2026-05-05 10:32:13 +02:00
auth-mode.mjs feat(ms-ai-architect): add lib/auth-mode for cron-safe auth detection [skip-docs] 2026-05-05 10:52:53 +02:00
backup.mjs feat(ms-ai-architect): add lib/backup with sentinel-guarded rollback [skip-docs] 2026-05-05 10:50:10 +02:00
cost-estimat.mjs feat(ms-ai-architect): add lib/cost-estimat heuristic for API-key budget [skip-docs] 2026-05-05 10:34:37 +02:00
cross-platform-paths.mjs feat(ms-ai-architect): add lib/cross-platform-paths for cache/log/state/backup dirs [skip-docs] 2026-05-05 10:30:31 +02:00
lock-file.mjs feat(ms-ai-architect): add lib/lock-file with PID+mtime stale detection [skip-docs] 2026-05-05 10:47:05 +02:00
log-rotate.mjs feat(ms-ai-architect): add lib/log-rotate for bounded log disk use [skip-docs] 2026-05-05 10:54:50 +02:00
registry-io.mjs feat(ms-ai-architect): sitemap-based KB change detection system 2026-04-09 21:19:51 +02:00
sitemap-stream.mjs feat(ms-ai-architect): sitemap-based KB change detection system 2026-04-09 21:19:51 +02:00
url-normalize.mjs feat(ms-ai-architect): sitemap-based KB change detection system 2026-04-09 21:19:51 +02:00