(projectRoot, now = new Date())
| 603 | // Reads .planning/telemetry/routine-runs.jsonl, one record per quota-consuming |
| 604 | // run: {ts, kind}. Nothing in the harness writes this file yet; remote-run |
| 605 | // logging populates it when a routine mechanism is actually used. |
| 606 | function readRoutineQuota(projectRoot, now = new Date()) { |
| 607 | const filePath = path.join(projectRoot, '.planning', 'telemetry', 'routine-runs.jsonl'); |
| 608 | const detail = readJsonlDetailed(filePath); |
| 609 | const windowStart = now.getTime() - 24 * 60 * 60 * 1000; |
| 610 | |
| 611 | let runsLast24h = 0; |
| 612 | if (detail.exists) { |
| 613 | for (const entry of detail.entries) { |
| 614 | const ts = new Date(entry.ts || entry.timestamp || 0).getTime(); |
| 615 | if (Number.isFinite(ts) && ts >= windowStart) runsLast24h++; |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | return { |
| 620 | sourceExists: detail.exists, |
| 621 | cap: ROUTINE_QUOTA_CAP, |
| 622 | runsLast24h, |
| 623 | warning: runsLast24h > ROUTINE_QUOTA_WARN_ABOVE, |
| 624 | }; |
| 625 | } |
| 626 | |
| 627 | function readQueueCounts(projectRoot) { |
no test coverage detected