Phase 2: analysis layer (analyze.js), cache guard, log hygiene

- analyze.js: burn rate, weekly reconstruction, cycle stagger, rotation
  rank, underspend alerts, log prune with weekly archive
- logger.js: getCachedRun(maxAgeMinutes) — skip probing if recent data exists
- monitor.js: cache guard at wake — 20-min dedup, zero extra API calls
- test.js: fix type assertion for gemini-api/xai-api providers (+5 passing);
  add 14 new tests for cache guard and analyze.js (162 total, all green)
- docs/analyze.md: usage reference

Co-authored-by: Hannibal Smith <hannibal@trentuna.com>
This commit is contained in:
Hannibal Smith 2026-04-05 04:49:05 +00:00
parent 1b4e299461
commit 34898b1196
Signed by: hannibal
GPG key ID: 6EB37F7E6190AF1C
6 changed files with 745 additions and 2 deletions

View file

@ -58,6 +58,20 @@ async function probeProvider(p) {
}
async function main() {
// Cache guard — return last logged run if within 20 minutes (skip on --summary, --no-log, --provider filter)
if (!noLog && !filterProvider && !isSummaryOnly) {
const { getCachedRun } = await import('./logger.js');
const cached = getCachedRun(20);
if (cached) {
if (isJson) {
console.log(JSON.stringify(cached, null, 2));
} else {
console.log(generateReport(cached));
}
return;
}
}
const allProviders = getProviders();
const providerNames = filterProvider
? [filterProvider]