Commit 79470e9
authored
upload-claude-usage: don't misattribute scheduled runs to a person (#8138)
## Problem
`misc.claude_code_usage` attributes a large, growing share of Claude
Code spend to individual maintainers who never ran it. Concrete example
— a single real row from the table:
| timestamp | repo | actor | event_name | pr_number | cost | turns |
|---|---|---|---|---|---|---|
| 2026-06-02 14:10 | meta-pytorch/pytorch-gha-infra | ZainRizvi |
`schedule` | 0 | \$1.52 | 42 |
That row is **not** Zain's usage. It's the hourly `Claude Infra
Investigations` cron (treehugger) in `meta-pytorch/pytorch-gha-infra`.
For `schedule` events there is no human trigger, so GitHub sets
`github.actor` to whoever last committed to the workflow file — which
happens to be the maintainer who set it up. At ~24 runs/day this funnels
all automated treehugger cost onto one person's name in the dashboard.
The same applies to any other scheduled Claude workflow (e.g.
`claude-distributed-triage-cron`).
## Fix
This action records `github.actor` verbatim. For `schedule` events,
record the **workflow name** (suffixed with `(scheduled)`) instead, so
the rows are clearly automated and stay distinguishable per-workflow.
`event_name` is still stored unchanged, so no signal is lost.
Human-triggered runs (`issue_comment`, `issues`, `workflow_dispatch`,
`pull_request`, …) keep `github.actor` exactly as before.
## Notes / follow-ups
- `workflow_run`-triggered runs inherit the upstream actor, so chains
rooted at a cron may still carry a stale actor; that path isn't touched
here. If desired, a follow-up could also remap `workflow_run` when the
upstream event was scheduled.
- Dashboards reading this table can additionally group by `event_name`
to separate automated vs. human usage.1 parent e50c021 commit 79470e9
1 file changed
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
35 | 47 | | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
39 | 51 | | |
40 | | - | |
| 52 | + | |
41 | 53 | | |
42 | 54 | | |
43 | 55 | | |
| |||
0 commit comments