Repository navigation
feat(run-claude-cli): record per-leg token usage and rate-limit windows, warn near a limit - #889
Conversation
…ws, warn near a limit The launcher's credential-scanned log now records, per leg, each subscription rate-limit window's highest utilization, newest reset and last status from stream-json rate_limit_event messages, beside the token usage it already kept. report-lane-outcome takes that log as a new log-file input and adds usage and windows to the lane-outcome record, read from the log only, never the execution file. A window at allowed_warning or rejected, or at 0.70 utilization or more, writes one warning annotation naming the leg's secret after the stop-commands block. Fields are additive, so the record stays v1 (docs/lane-outcome.md, Compatibility). Past 1,024 characters the record drops models, then usage, then windows. Co-authored-by: Claude Opus 5.5 <[email protected]>
… snake_case python.md documents RateLimitInfo in snake_case (rate_limit_type, resets_at) while the TypeScript reference and the existing reads use camelCase, and no real CI stream has shown which the CLI emits. One normalizer now reads each field in either form for both the window record and the limit-stop reset, so a wrong guess no longer drops the data silently. A test pins that a rejected window below 0.70 gets the usage warning line. Co-authored-by: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Claude finished @kyle-sexton's task in 2m 9s —— View job Security review complete
No security issues found in this PR. What was checked:
Actions hardening (trigger types, critical-findings: 0 claude-lane-summary: lane=claude-security-review sha=da31296c3e7d98c7db3aaed511ffd01fe78ba804 run=40242353031 |
|
Claude finished @kyle-sexton's task in 4m 56s —— View job Code review complete
SummaryNo findings survived review. Walked through
claude-lane-summary: lane=claude-review sha=da31296c3e7d98c7db3aaed511ffd01fe78ba804 run=40242353031 |
|
claude-security-review has reviewed this pull request through da31296; a later push is reviewed from there. |
|
claude-review has reviewed this pull request through da31296; a later push is reviewed from there. |
… and pr-review-cli contracts (#880) Refs: melodic-software/ci-workflows#889 ## Summary Registers the `intake-triage.yml` and `pr-review-cli.yml` reusable-workflow contracts at ci-workflows [v0.65.11](https://github.com/melodic-software/ci-workflows/releases/tag/v0.65.11) (`e5167fc29d948ab7d0923cf62f5ea9eeeef8e9e8`), so claude-code-plugins can repin its intake and review callers and pass runner-policy. ## Fix - Copies the v0.65.10 `intake-triage` entry (`@215cec5c362f953f8b6196effb04451696c3f970`) and the v0.65.9 `pr-review-cli` entry (`@4fbceb4b75ffd568dfa5db31de0d0e753c0c64e6`) forward verbatim in `components/runner-policy/policy.json`. Past entries stay. - Adds the matching copy-forward test in `runner-policy.test.mjs` and a rollout line in the component README. - v0.65.11 ([ci-workflows#889](melodic-software/ci-workflows#889)) passes `log-file` to `report-lane-outcome`, which records per-leg token usage and rate-limit windows. In both workflows the diff adds only that `with:` line: no input, secret or job permission changes. ## Verification - `node --test components/runner-policy/runner-policy.test.mjs`: 353 pass, 0 fail. - `node components/runner-policy/runner-policy.mjs --root <worktree>`: Runner policy passed. - Pre-commit biome and markdownlint: clean. ## Related - [melodic-software/ci-workflows#889](melodic-software/ci-workflows#889) (released as v0.65.11) - [#879](#879) (v0.65.10 intake contract), [#878](#878) (v0.65.9 review contract) - Next: the standards sync into claude-code-plugins, then the lane caller repin. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Refs: #885
Summary
The owner approved an early warning before a lane's subscription runs out (W7, 2026-10-25, from the Lane Funding work in melodic-software/claude-code-plugins). Today the launcher drops every
rate_limit_eventexceptrejected(classify.cjslimitStopFrom), and the lane-outcome record carries no token counts. So nothing warns before a stop, and no per-leg load figure reaches the record. This PR adds both, read from the credential-scanned log.This covers the tokens item of #885. It does not cover that issue's
durationMsor run-link items, so the issue stays open. #885 lists "usage percentages" as out of scope. The W7 decision on 2026-10-25 brings window utilization into the record, so this PR does that.Fix
run-claude-cliwritesrate_limitsinto each leg's scanned log record. For each documented window (five_hour,seven_day,seven_day_opus,seven_day_sonnet,overage) it holds the highestutilizationseen during the leg, rounded to 2 decimals, plus the newest event'sresets_atandstatus. A window whose events never carry a utilization has none recorded, never 0. The log already held token usage.allowed_warningorrejected, or utilization of 0.70 or more, the launcher writes one::warning title=run-claude-cli usage::annotation. It names the leg's secret (never its value), each qualifying window, its utilization, status and reset. The annotation is written after the::stop-commands::block ends and before a lane-class failure ends the step.report-lane-outcometakes a new optionallog-fileinput. It re-checks every value in the log against closed patterns, then addsusage(input,output,cacheRead,cacheCreation) andwindowsto the lane-outcome record. These values come from that log only, never from the execution file. Intake triage and pr-review-cli pass the input at all four call sites.v: 1, because new fields are additive underdocs/lane-outcome.md§ Compatibility. The schema and doc now describe both fields. A record over 1,024 characters dropsmodelsfirst, thenusage, thenwindows. No new legacykey=valuetokens are added.Verification
node --test .github/scripts/*.test.cjs: 709 pass, 0 fail.node --test .github/actions/report-lane-outcome/*.test.cjs: 84 pass, 0 fail.node --test .github/actions/run-claude-cli/*.test.cjs: 75 pass, 0 fail. The new tests cover each window's max utilization and newest status, forged log values being dropped, schema validation, the worst-case 1,024-character drop order, the warning threshold (0.69 gives no warning, 0.70 warns), and the warning's position after the stop-commands block.actionlintpasses on both edited workflows, andmarkdownlint-cli2passes on the doc.rate_limit_infofield is read in both forms, camelCase (rateLimitType,resetsAt, as in the TypeScriptSDKRateLimitEvent) and snake_case (rate_limit_type,resets_at, as in the PythonRateLimitInfo), with a test for each. Neither form has yet been seen in a real CI stream.Related
RateLimitInfoand TypeScriptSDKRateLimitEvent.🤖 Generated with Claude Code