|
1 | 1 | # HANDOFF — github-api-usage-monitor |
2 | 2 |
|
3 | | -**Date:** 2026-01-25 |
4 | | -**Branch:** `build-spec` |
5 | | -**Status:** v1 implementation complete, ready for integration testing |
| 3 | +**Date:** 2026-01-31 |
| 4 | +**Branch:** `claude` |
| 5 | +**Status:** v1 implementation complete, self-test suite operational, code review fixes applied |
6 | 6 |
|
7 | 7 | --- |
8 | 8 |
|
@@ -32,39 +32,45 @@ A GitHub Action that monitors API rate-limit usage during a workflow job by poll |
32 | 32 |
|
33 | 33 | ### Test Status |
34 | 34 |
|
35 | | -- **67 tests passing** across 4 test files |
36 | | -- TypeScript: clean |
37 | | -- ESLint: clean |
38 | | -- Build: `dist/main.js` (991KB) + `dist/poller/index.js` (28KB) |
| 35 | +- **128 tests passing** across 6 test files |
| 36 | +- TypeScript: clean (strict mode) |
| 37 | +- ESLint: clean (`no-explicit-any` enforced) |
| 38 | +- Build: 4 ncc bundles — `dist/main.js`, `dist/pre.js`, `dist/post.js`, `dist/poller/index.js` |
39 | 39 |
|
40 | 40 | --- |
41 | 41 |
|
42 | 42 | ## Architecture Summary |
43 | 43 |
|
44 | 44 | ``` |
45 | | -Workflow Step: start |
| 45 | +pre.ts → start.ts (action.yml pre hook) |
46 | 46 | │ |
47 | 47 | ├── Validate platform (Linux/macOS only) |
48 | 48 | ├── Initial poll to /rate_limit (fail-fast token validation) |
49 | 49 | ├── Create initial state with baseline |
50 | 50 | ├── Spawn detached poller process |
51 | | - └── Write PID to $RUNNER_TEMP |
| 51 | + ├── Write PID to $RUNNER_TEMP |
| 52 | + └── Verify poller startup (poll state.json for poller_started_at_ts) |
52 | 53 |
|
53 | | -Poller (background, every 30s) |
| 54 | +Poller (detached child process, adaptive interval) |
54 | 55 | │ |
55 | 56 | ├── GET /rate_limit |
56 | 57 | ├── Reduce: calculate deltas per bucket |
57 | 58 | │ ├── Same window: delta = used - last_used |
58 | 59 | │ ├── New window: total += used (post-reset) |
59 | 60 | │ └── Anomaly: used decreased without reset |
60 | | - └── Atomic write state.json |
| 61 | + ├── Atomic write state.json |
| 62 | + └── Append to poll-log.jsonl (diagnostic JSONL log) |
61 | 63 |
|
62 | | -Workflow Step: stop (always) |
| 64 | +main.ts (no-op, required by action.yml) |
| 65 | +
|
| 66 | +post.ts (action.yml post hook, runs always) |
63 | 67 | │ |
64 | | - ├── Kill poller by PID (SIGTERM) |
| 68 | + ├── Kill poller by PID (SIGTERM → SIGKILL escalation) |
| 69 | + ├── Perform final API poll |
65 | 70 | ├── Read final state |
66 | 71 | ├── Generate warnings |
67 | | - └── Render summary to $GITHUB_STEP_SUMMARY + console |
| 72 | + ├── Render summary to $GITHUB_STEP_SUMMARY + console |
| 73 | + └── Expose state_json and poll_log_json as action outputs |
68 | 74 | ``` |
69 | 75 |
|
70 | 76 | --- |
@@ -107,23 +113,20 @@ See `docs/planning/IMPL-PLAN-declarative-self-test.md` for full design. |
107 | 113 |
|
108 | 114 | ## Next Steps |
109 | 115 |
|
110 | | -1. **Verify self-test workflow** — Run via workflow_dispatch on GitHub and confirm all 12 scenarios produce expected state.json output |
111 | | -2. **Consider test isolation** — Dedicated repo or reserved token to avoid cross-workflow rate-limit noise |
112 | | -3. **Test edge cases**: |
113 | | - - Token with no permissions |
114 | | - - Very short job (< 30s) |
115 | | - - Multiple window resets during job |
| 116 | +1. **Write README.md** — Usage examples, inputs/outputs reference, example summary output |
| 117 | +2. **Increase test coverage** — poller lifecycle (20%), post.ts (0%), pre.ts (0%), poll-log.ts (0%) |
| 118 | +3. **Consider test isolation** — Dedicated repo or reserved token to avoid cross-workflow rate-limit noise |
116 | 119 | 4. **Consider adding**: |
117 | | - - Debug log file for poller (currently silent) |
118 | 120 | - `report_buckets` input for filtering output (v2) |
| 121 | + - Threshold-based alerting (warn/fail when usage exceeds percentage) |
119 | 122 |
|
120 | 123 | --- |
121 | 124 |
|
122 | | -## Outstanding Questions |
| 125 | +## Resolved Questions |
123 | 126 |
|
124 | | -1. **Poller log file** — Should the poller write debug logs to a file? Currently uses `stdio: 'ignore'`. Could add `$RUNNER_TEMP/github-api-usage-monitor/poller.log`. |
| 127 | +1. **Poller log file** — Resolved: poller writes diagnostic JSONL to `$RUNNER_TEMP/github-api-usage-monitor/poll-log.jsonl` via `poll-log.ts`. Exposed as `poll_log_json` action output. |
125 | 128 |
|
126 | | -2. **dist/ in repo** — Should `dist/` be committed to the repo (common for Actions) or generated on release? Currently gitignored. |
| 129 | +2. **dist/ in repo** — Resolved: `dist/` is committed to git. Pre-commit hook verifies it stays in sync after `build:all`. CI also verifies. |
127 | 130 |
|
128 | 131 | --- |
129 | 132 |
|
|
0 commit comments