What the factory costs to run
On this page
One command says what a project's factory cost over the last days: the machine minutes its workflows used, and what its calls to a model spent. It only reads, and keeps nothing. The app shows the same report, and keeps a short history of it.
GITHUB_REPOSITORY=owner/repo GITHUB_TOKEN=$(gh auth token) python3 -m factory.cost
GITHUB_REPOSITORY=owner/repo GITHUB_TOKEN=$(gh auth token) python3 -m factory.cost --days 30 --exact
GITHUB_REPOSITORY=owner/repo GITHUB_TOKEN=$(gh auth token) python3 -m factory.cost --no-lines-or-hoppers
What the factory at owner/repo cost to run, last 7 days
Machine minutes: $3.54 at list price, over 488 workflow runs.
Model calls: $1.20 at list price, over 31 calls.
workflow runs minutes machines calls model
the review gate 216 216 $1.30
the automatic reviewer 107 209 $1.25 29 $1.05
tests.yml 165 165 $0.99
the builder 2 9 $0.05 2 $0.15
#Two kinds of cost
Machine minutes. Every workflow run in the period, from GitHub's own list, priced by the minute.
- By default a run counts from its start to its end, rounded up to a minute. That is one question to GitHub for a hundred runs. It is close for a run whose jobs follow one another, short for one whose jobs run side by side, and long for one that waited: a run held for a person's approval, or for a free machine, counts its wait, and only the last try of a run that was run again is counted.
--exactadds up each job's minutes, rounded up as GitHub bills them, by the kind of machine. It asks GitHub once more for every run, so use it for a figure to rely on, not for a quick look. A machine of your own, or a larger one, is priced as a standard Linux machine unless you give another price.- Prices are US dollars a minute:
--linux(0.006),--windows(0.010),--macos(0.062), GitHub's list prices for its standard machines in 2026. Give your own for larger machines or another year. - It is not a bill. GitHub does not charge a public repository for standard machines, and a private one's plan includes minutes. The figure is what the minutes are worth at list price, so that one project, one week or one workflow can be compared with another.
Model calls. Since version 0.59.0 every call the factory makes to a model (the automatic reviewer, the builder, the hopper review, the reviewer's health check) leaves a note on its run: the tokens used, and the model program's own estimate of the cost at list prices. The report reads those notes back.
- The note holds numbers and a model's name, and nothing the model wrote. Anybody who can read the run can read it.
- On a subscription no call is charged. The figure is what the same calls would have cost on a key.
- Runs from before 0.59.0 carry no note and count as having none. The reusable workflow a project calls must be at 0.59.0 or later for its calls to be noted.
#Cost against outcome
The report also says what the spending went on, by how each change ended:
What it went on, by how each change ended (as each stands now):
merged 27 changes 109 runs machines $0.66 model $0.41 $0.04 each
in the bin 1 change 3 runs machines $0.02 model $0.15 $0.17 each
closed without merging 1 change 2 runs machines $0.14 model $0.00 $0.14 each
still open 2 changes 6 runs machines $0.04 model $0.00 $0.02 each
on no one change 140 runs machines $1.00 model $0.00
- How a change ended is how it stands when the report is made: merged; in the bin (it carries the factory file's
bin.labeland is not merged); closed without merging; or still open. A change taken out of the bin tomorrow is counted differently tomorrow. - Which change a run was for. GitHub ties a run to a change only while the change is open, so the report ties them itself. A run a pull request started, or a push to a change's own branch, belongs to the change whose branch it ran on, while that change was open. A builder's run belongs to the change opened from a
factory/item-branch while it ran. Where two changes fit, the run is given to neither. - A run a comment started is tied by title. The review gate runs when a review record is posted, and GitHub does not say which change such a run was for: it gives the run the title of what was commented on, as it was then. The run is put to a change only when exactly one change read has that exact title and was open at the time. A change renamed since, two changes with one title, or a comment on a request that is not a change, leave the run on no change. One thing it can get wrong: a comment on a request (an issue) whose title is, word for word, that of one open change is taken for the change's.
- On no one change is everything else: runs started by a schedule, a release, a push to the main branch, a comment whose title is no one open change's, a builder's run that opened no change or built one again. The table of workflows above says what those runs were.
- The changes read are those touched in the period, at most 1,000; the report says when there were more.
- The five changes that cost most are listed with how each ended. In
--json:outcomes,on_no_change,changes(each withended) andchanges_cut_short.
#By release line and by hopper
When the factory file has release lines, or hoppers, the report adds a small table for each:
By release line (the changes whose files feed each; one question to GitHub for each of 31 changes):
api 19 changes 84 runs machines $0.52 model $0.38
site 9 changes 27 runs machines $0.16 model $0.11
on no line 4 changes 11 runs machines $0.07 model $0.07
What the builder built, by the hopper each request came from:
bugs 2 changes 9 runs machines $0.06 model $0.31
- A change is on a line when a file it changes is one the line's
feedsname (either name of a renamed file). A change on two lines is counted under each, and the report says so when that happens: the rows then add up to more than was spent. - What it costs to ask. GitHub's list of changes does not say which files each changes, so every change that had a run is asked about: one more question to GitHub for each, for its first hundred files. A change with a hundred files or more may be on a line that only its later files feed; the report says how many such changes there were. At most 500 changes are asked about, the dearest first; the rest are a row of their own, "not asked about".
- A built change's hopper. A change the builder built comes from a
factory/item-<n>branch of the repository itself, and request<n>'s hopper is the first in the factory file whose label the request carries when the report is made: one more question for each request built for, however many changes were built for it. A request that has lost its label, or is gone, puts its change under "no hopper now". What the builder's own run spent is in the change's figure, with the reviews and tests that followed. A builder's run that opened no change is on no change, and so in no hopper's row. - Neither table is made, and nothing more is asked, when the factory file has no lines (or no hoppers), or has them in a form the factory cannot use.
--no-lines-or-hoppersleaves both tables out, and asks none of those questions: for a quick look at a project with many changes. The rest of the report is the same.- In
--json:by_line(lines,on_no_line,not_asked,asked,more_files) andby_hopper(hoppers,no_hopper,asked); each isnullwhen the factory file has none.
#What it names
A workflow file named factory… under a name the factory does not know (factory-shadow.yml, say) is read once, and named for the one kind of the factory's workflows it calls. A workflow file with an ordinary name (review.yml, gate.yml, builder.yml and the like) is taken for the factory's only when its own text calls the factory; otherwise it is listed as the project's own. Its text, not its comments: a line beginning #, or what follows # on a line, tells nothing. What tells is a step that runs one of the factory's programs (python3 -m factory.…), a uses: that calls a workflow of a repository called factory, or a uses: that calls a workflow and hands it factory_ref (as each of the factory's workflows asks, so a copy of the factory kept under another name is known too). A file that is not there is the project's own. If GitHub will not let the file be read (refused, or failing), the report says NOT CHECKED and names it: it is then listed as the project's own and no model calls are read for it, which may be short. In --json: names_not_checked. The factory's own workflows are named as the factory knows them (the review gate, the automatic reviewer, the builder, the hopper review, leftovers, the health check), and each release line's workflow and watch are named from the factory file. Everything else is the project's own, most often its tests, and is listed by its file's name.
"The changes that cost most" adds up the runs GitHub ties to one change. GitHub ties a run to a change only while the change is open and comes from the repository itself, so this is a guide to which open work is expensive, not a full account.
#In the app
The app has a "Cost" button. It opens a window with this report for the last seven days, in the quick way (not --exact), with the tables by release line and by hopper when the factory file has them: the totals, the table of workflows, the table by how each change ended, and the five changes that cost most. It says, as the command does, that the figures are at list price and are not a bill.
- It is worked out only when somebody presses "Cost". A report is several hundred questions to GitHub, and far more on a busy project, so no ordinary reading of the floor makes one. One is worked out at a time.
- The answer is kept for an hour. Pressing "Cost" again within the hour shows the kept report and says how old it is. On a hosted floor the kept report is everybody's who is let in: whoever asks first pays for it from their own GitHub allowance, and the rest are given it. Nothing in the report depends on who asked: it is made of the project's workflow runs, their notes, its changes and their files and labels, which everybody who may read the project may read.
- A short history is kept. Each time a fresh report is made, a small dated summary of it is kept with the app's history: the day, the totals, and the rows by how each change ended. Not the workflows, and not any change. One is kept for a day (a later report the same day takes its place), and the last ninety. The window shows them as a small chart and a table, so you can see how the cost has moved. Each is a report of the seven days up to its date, so neighbouring ones overlap: they are for comparing, not for adding up. A history begins the first time "Cost" is pressed, and has a row only for the days it was.
- The API gives the same answer as data.
#What it does not do
- It does not know what a project actually pays: the plan, included minutes, discounts and a subscription's price are not GitHub's to tell.
- It does not count what the project's own release spends at its host.
- GitHub lists at most 1,000 runs for any one day. The report asks a day at a time, and says so when a day had more: its figures are then short.
- The model figure is only as trustworthy as the people who can change the project's workflows: a workflow with one of the factory's file names can write any note it likes. Nothing is decided by it.
- A project that calls the reviewer or the builder from a workflow file with another name gets no model figure for it: the report reads notes only on the factory's own file names.
- The command keeps no history. Run it when you want to know;
--jsongives the same report for anything that wants to keep it. Only the app keeps one, and a short one.
This guide is docs/COST.md in the repository, and this page is made from it. Something wrong or unclear? Open an issue or send a pull request. Next: Asking the factory from an agent.