Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means. | 1 | /** |
| The site no longer has g1t's own agents. g1t is where the coding agents you already use do their work, so the Agents mode is gone from the rail, with every page under /<workspace>/-/agents: personas, faces, skills, abilities, routines, computers, sessions and agent spend. Customize (skills, connectors, plugins, marketplaces), the context hub, model providers, the AI Gateway page, the Spend page and pill, Ask g1t, and the repository's Agents, Plans and agent settings pages go too, and their addresses now answer 404. | 2 | * One month, one number: Home's "this month so far" and Usage's "This |
| 3 | * range" show the same figure for the same month, formatted the same way. Each surface's arithmetic is the | |
| Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means. | 4 | * pure function its loader or component calls; the loaders only fetch. |
| 5 | */ | |
| 6 | import assert from "node:assert/strict"; | |
| 7 | import { test } from "node:test"; | |
| 8 | ||
| 9 | import type { Statement, UsageReport } from "@g1t/contracts"; | |
| 10 | ||
| 11 | import { spendIn } from "./home.ts"; | |
| 12 | import { money } from "./money.ts"; | |
| The site no longer has g1t's own agents. g1t is where the coding agents you already use do their work, so the Agents mode is gone from the rail, with every page under /<workspace>/-/agents: personas, faces, skills, abilities, routines, computers, sessions and agent spend. Customize (skills, connectors, plugins, marketplaces), the context hub, model providers, the AI Gateway page, the Spend page and pill, Ask g1t, and the repository's Agents, Plans and agent settings pages go too, and their addresses now answer 404. | 13 | import { monthSpan, pendingSentence, receipt, resolveRange } from "./usage.ts"; |
| Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means. | 14 | |
| 15 | const NOW = new Date("2026-10-10T18:30:00Z"); | |
| 16 | ||
| 17 | /** A comped workspace in October: $10.401 on the ledger, $0.009 of storage metered and not yet closed, a 100% discount. */ | |
| 18 | const report = { | |
| 19 | from: "2026-10-01", | |
| 20 | until: "2026-10-10", | |
| 21 | totals: { | |
| 22 | priceMicros: 10_410_000, | |
| 23 | discountMicros: 10_410_000, | |
| 24 | includedMicros: 0, | |
| 25 | creditsMicros: 0, | |
| 26 | chargedMicros: 0, | |
| 27 | pendingMicros: 9_000, | |
| 28 | pendingChargedMicros: 0, | |
| 29 | costMicros: 8_670_000, | |
| 30 | }, | |
| 31 | days: [], | |
| 32 | products: [], | |
| 33 | projects: [], | |
| 34 | discountPercent: 100, | |
| 35 | aiCreditMicros: 0, | |
| 36 | creditMicros: 0, | |
| 37 | plan: "paid", | |
| 38 | free: false, | |
| 39 | } satisfies UsageReport; | |
| 40 | ||
| 41 | /** The same month's statement: the ledger's lines only, which is why Home no longer reads its total for the month. */ | |
| 42 | const statement = { | |
| The site no longer has g1t's own agents. g1t is where the coding agents you already use do their work, so the Agents mode is gone from the rail, with every page under /<workspace>/-/agents: personas, faces, skills, abilities, routines, computers, sessions and agent spend. Customize (skills, connectors, plugins, marketplaces), the context hub, model providers, the AI Gateway page, the Spend page and pill, Ask g1t, and the repository's Agents, Plans and agent settings pages go too, and their addresses now answer 404. | 43 | groups: [{ key: "2026-10-09", label: "", chargedMicros: 0, lines: [{ kind: "Sandboxes", count: 3, chargedMicros: 0, costMicros: 8_670_000, priceMicros: 10_401_000 }] }], |
| Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means. | 44 | totals: { chargedMicros: 0, paidMicros: 0, costMicros: 8_670_000, entries: 3, priceMicros: 10_401_000 }, |
| 45 | } satisfies Pick<Statement, "groups" | "totals">; | |
| 46 | ||
| 47 | test("every page asks billing for the same month", () => { | |
| 48 | const month = monthSpan(NOW); | |
| 49 | assert.deepEqual(month, { from: "2026-10-01", until: "2026-10-10" }); | |
| The site no longer has g1t's own agents. g1t is where the coding agents you already use do their work, so the Agents mode is gone from the rail, with every page under /<workspace>/-/agents: personas, faces, skills, abilities, routines, computers, sessions and agent spend. Customize (skills, connectors, plugins, marketplaces), the context hub, model providers, the AI Gateway page, the Spend page and pill, Ask g1t, and the repository's Agents, Plans and agent settings pages go too, and their addresses now answer 404. | 50 | // Home (lib/home.server.ts `loadSpend`) and Usage (routes/workspace/usage.tsx `readFilters`). |
| Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means. | 51 | const { from, until } = resolveRange("cycle", {}, NOW); |
| 52 | assert.deepEqual({ from, until }, month); | |
| 53 | }); | |
| 54 | ||
| The site no longer has g1t's own agents. g1t is where the coding agents you already use do their work, so the Agents mode is gone from the rail, with every page under /<workspace>/-/agents: personas, faces, skills, abilities, routines, computers, sessions and agent spend. Customize (skills, connectors, plugins, marketplaces), the context hub, model providers, the AI Gateway page, the Spend page and pill, Ask g1t, and the repository's Agents, Plans and agent settings pages go too, and their addresses now answer 404. | 55 | test("Home and Usage show one figure for the month", () => { |
| 56 | // Home's "this month so far" (lib/home.server.ts `loadSpend` hands `spendIn` the report's usage at price; components/home.tsx `SpendCard`). | |
| 57 | const home = spendIn([statement], { from: Date.parse("2026-10-09T00:00:00Z"), now: NOW.getTime() }, report.totals.priceMicros); | |
| Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means. | 58 | const homeMonth = money(home.monthMicros!); |
| 59 | // Usage's "This range", first line (components/usage.tsx `IncludedAndCredit`: `receipt`, then `money(line.micros)`). | |
| 60 | const lines = receipt(report.totals, report.discountPercent); | |
| 61 | const usage = money(lines[0]!.micros); | |
| 62 | ||
| The site no longer has g1t's own agents. g1t is where the coding agents you already use do their work, so the Agents mode is gone from the rail, with every page under /<workspace>/-/agents: personas, faces, skills, abilities, routines, computers, sessions and agent spend. Customize (skills, connectors, plugins, marketplaces), the context hub, model providers, the AI Gateway page, the Spend page and pill, Ask g1t, and the repository's Agents, Plans and agent settings pages go too, and their addresses now answer 404. | 63 | assert.equal(homeMonth, "$10.41"); |
| 64 | assert.equal(usage, homeMonth); | |
| Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means. | 65 | |
| 66 | // The statement alone, which Home used to show, is the $0.009 short that read as a rounding difference. | |
| 67 | assert.equal(money(statement.totals.priceMicros), "$10.40"); | |
| 68 | ||
| 69 | // The rest of Usage's receipt for the same report, as the page writes each line. | |
| 70 | assert.deepEqual( | |
| 71 | lines.map((line) => `${line.label} ${line.minus ? "−" : ""}${money(line.micros)}`), | |
| 72 | ["Usage at price $10.41", "Discount (100%) −$10.41", "Charged $0.00"], | |
| 73 | ); | |
| 74 | assert.equal( | |
| 75 | pendingSentence(report.totals), | |
| 76 | "$0.009 of it is metered this month and not yet closed; nothing will be charged when the month closes, after your discount and included usage.", | |
| 77 | ); | |
| 78 | }); |