Skip to content
506 linesCodeBlameRaw

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.

Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays1import type { ReactNode } from "react";
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing2import { Link } from "react-router";
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily3
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing4import type { CostsReport } from "@g1t/contracts";
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily5
6import type { Route } from "./+types/costs";
7import { DaysChart } from "~/components/costs";
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing8import { CostsHeader, chip, costsHref } from "~/components/costs-header";
9import { Badge, Button, Field, Input, Notice, Section, Stat, When } from "~/components/ui";
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly10import { capPercent, daySeries, marginOnPrice, marginTone, parseBucket, percentLabel, spendRows, subscriptionsOver, whoPaid } from "~/lib/costs";
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing11import { type CostsActionResult, costsAction, costsLoader } from "~/lib/costs-route.server";
12import { usd } from "~/lib/money";
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily13
14export const meta: Route.MetaFunction = () => [{ title: "Costs & margin · sudo" }, { name: "robots", content: "noindex, nofollow" }];
15
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly16/** Billing's MARGIN_PERCENT: what is added to cost. */
17const MARKUP_PERCENT = 20;
18
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing19export const loader = ({ request, context }: Route.LoaderArgs) => costsLoader(request, context);
20export const action = ({ request, context }: Route.ActionArgs) => costsAction(request, context);
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily21
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing22/**
23 * Where g1t's money goes: the statement, what g1t pays for itself against
24 * its caps, and the same by day, by product and by workspace.
25 */
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily26export default function Costs({ loaderData, actionData }: Route.ComponentProps) {
27 const { range, report, error, done } = loaderData;
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing28 const failed = actionData && "error" in actionData ? (actionData as CostsActionResult) : null;
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly29 const description = `What g1t cost to run (Cloudflare's bill and the model providers') against what workspaces paid, with what g1t gave away on purpose kept apart. Prices are cost plus ${MARKUP_PERCENT}%, a ${percentLabel(marginOnPrice(MARKUP_PERCENT))} margin: every margin here is a share of the price, not of the cost. The bill itself, drift and the price book are on Bill & pricing.`;
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily30 if (!report) {
31 return (
32 <main className="mx-auto max-w-6xl px-4 py-8 sm:py-10">
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing33 <CostsHeader page="costs" range={range} report={null} done={null} runError={null} description={description} />
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily34 <div className="mt-5">
35 <Notice tone="warn">Billing did not answer for costs: {error}</Notice>
36 </div>
37 </main>
38 );
39 }
40 const bucket = parseBucket(loaderData.bucket, report.products.map((p) => p.bucket));
41 const product = report.products.find((p) => p.bucket === bucket) ?? null;
42 const series = daySeries(report.days, report.since, report.until, bucket);
43 const floor = report.settings.marginFloorPercent;
44 const open = report.proposals.filter((p) => p.status === "open");
45 return (
46 <main className="mx-auto max-w-6xl px-4 py-8 sm:py-10">
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing47 <CostsHeader page="costs" range={range} report={report} done={done} runError={failed?.section === "run" ? failed.error : null} description={description} />
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily48
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running49 <Statement report={report} floor={floor} range={range} proposals={open.length} />
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily50
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly51 <SpendSection caps={report.caps} range={range} error={failed?.section === "lift" ? failed.error : null} />
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays52
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily53 <Section
54 className="mt-6"
55 title={product ? `${product.title}, by day` : "By day"}
56 description={
57 product
58 ? "What customers were charged for it at price, before included usage and pools paid part, against what it cost."
59 : "Money in (usage paid for and the plan) against every cost. Pick a product to see its own."
60 }
61 >
62 <nav aria-label="Product" className="mb-4 flex flex-wrap gap-2">
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing63 <Link to={costsHref("costs", range, null)} aria-current={!bucket ? "page" : undefined} className={chip(!bucket)}>
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily64 All of g1t
65 </Link>
66 {report.products.map((p) => (
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing67 <Link key={p.bucket} to={costsHref("costs", range, p.bucket)} aria-current={p.bucket === bucket ? "page" : undefined} className={chip(p.bucket === bucket)}>
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily68 {p.title}
69 </Link>
70 ))}
71 </nav>
72 <DaysChart
73 days={series}
74 floor={floor}
75 revenueLabel={product ? "Charged at price" : "Money in"}
76 label={product ? `${product.title}: charged against Cloudflare cost by day` : "Money in against Cloudflare cost by day"}
77 />
78 </Section>
79
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly80 <Section
81 className="mt-6"
82 title="By product"
83 description={`Each of g1t's products over the last ${range} days: what customers were charged at price, given away or not, against what it cost. The margin is the charge less the cost, as a share of the charge; at cost plus ${MARKUP_PERCENT}% it is ${percentLabel(marginOnPrice(MARKUP_PERCENT))}. The floor is ${floor}%.`}
84 >
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily85 <div className="-mx-4 overflow-x-auto sm:-mx-5">
86 <table className="w-full min-w-[44rem] text-sm">
87 <thead>
88 <tr className="border-b border-line text-left text-xs text-muted">
89 <th className="px-4 py-2 font-medium sm:px-5">Product</th>
90 <th className="px-4 py-2 text-right font-medium">Charged at price</th>
91 <th className="px-4 py-2 text-right font-medium">Cost</th>
92 <th className="px-4 py-2 text-right font-medium">Price book said</th>
93 <th className="px-4 py-2 text-right font-medium">Margin</th>
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly94 <th className="px-4 py-2 text-right font-medium sm:pr-5">% of price</th>
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily95 </tr>
96 </thead>
97 <tbody>
98 {report.products.map((p) => {
99 const tone = p.overhead ? undefined : marginTone(p.marginPercent, floor);
100 return (
101 <tr key={p.bucket} className="border-b border-line last:border-0">
102 <td className="px-4 py-2.5 sm:px-5">
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing103 <Link to={costsHref("costs", range, p.bucket)} className="text-fg hover:underline">
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily104 {p.title}
105 </Link>
106 <span className="block text-xs text-faint">
107 {p.overhead ? "Paid by the plan" : p.costSource === "ledger" ? "Cost from the gateway, not Cloudflare" : p.bucket}
108 </span>
109 </td>
110 <td className="tabular px-4 py-2.5 text-right">{usd(p.valueMicros)}</td>
111 <td className="tabular px-4 py-2.5 text-right">{usd(p.costMicros)}</td>
112 <td className="tabular px-4 py-2.5 text-right text-muted">{usd(p.ownCostMicros)}</td>
113 <td className={`tabular px-4 py-2.5 text-right ${p.marginMicros < 0 && !p.overhead ? "text-danger" : ""}`}>{usd(p.marginMicros)}</td>
114 <td className="px-4 py-2.5 text-right sm:pr-5">
115 {p.overhead ? (
116 <span className="text-faint">—</span>
117 ) : (
118 <Badge tone={tone === "mint" ? "mint" : tone === "warn" ? "warn" : tone === "danger" ? "danger" : "plain"}>{percentLabel(p.marginPercent)}</Badge>
119 )}
120 </td>
121 </tr>
122 );
123 })}
124 </tbody>
125 </table>
126 </div>
127 </Section>
128
129 <Section
130 className="mt-6"
131 title="Workspaces that cost most"
132 description="Cloudflare's costs shared out by each workspace's own meters (its git operations, its usage), against what it paid. Over its revenue for 30 days, a workspace shows on Reach out."
133 >
134 {report.topWorkspaces.length === 0 ? (
135 <p className="text-sm text-muted">No costs shared out yet.</p>
136 ) : (
137 <div className="-mx-4 overflow-x-auto sm:-mx-5">
138 <table className="w-full min-w-[34rem] text-sm">
139 <thead>
140 <tr className="border-b border-line text-left text-xs text-muted">
141 <th className="px-4 py-2 font-medium sm:px-5">Workspace</th>
142 <th className="px-4 py-2 text-right font-medium">Cost to g1t</th>
Costs: margin is measured on what was sold; comped workspaces, free periods, the trial and the pools are given away, a budget shown beside it143 <th className="px-4 py-2 text-right font-medium">Given away</th>
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily144 <th className="px-4 py-2 text-right font-medium">Paid</th>
145 <th className="px-4 py-2 text-right font-medium sm:pr-5">Net</th>
146 </tr>
147 </thead>
148 <tbody>
149 {report.topWorkspaces.map((w) => {
150 const net = w.revenueMicros - w.costMicros;
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly151 // What was given away on purpose is a budget, not a loss:
152 // red only for what neither paid nor was given.
153 const lost = net + (w.givenMicros ?? 0) < 0;
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily154 return (
155 <tr key={w.workspace} className="border-b border-line last:border-0">
156 <td className="px-4 py-2.5 sm:px-5">
157 <Link to={`/workspaces/${encodeURIComponent(w.workspace)}#billing`} className="font-mono text-fg hover:underline">
158 {w.workspace}
159 </Link>
160 {w.internal && <span className="ml-2 text-xs text-faint">g1t's own</span>}
161 </td>
162 <td className="tabular px-4 py-2.5 text-right">{usd(w.costMicros)}</td>
Costs: margin is measured on what was sold; comped workspaces, free periods, the trial and the pools are given away, a budget shown beside it163 <td className="tabular px-4 py-2.5 text-right text-fg-soft">{usd(w.givenMicros ?? 0)}</td>
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily164 <td className="tabular px-4 py-2.5 text-right">{usd(w.revenueMicros)}</td>
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly165 <td className={`tabular px-4 py-2.5 text-right sm:pr-5 ${lost && !w.internal ? "text-danger" : "text-fg-soft"}`}>{usd(net)}</td>
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily166 </tr>
167 );
168 })}
169 </tbody>
170 </table>
171 </div>
172 )}
173 </Section>
174
175 </main>
176 );
177}
178
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays179function CapMeter({ label, used, cap, hint }: { label: string; used: number; cap: number; hint: ReactNode }) {
180 const percent = capPercent(used, cap);
Merge branch 'worktree-agent-ad7c6d88d93adc817'181 const tone = cap > 0 && used >= cap ? "bg-danger" : percent >= 75 ? "bg-warn" : "bg-accent";
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays182 return (
183 <div className="rounded-md border border-line px-4 py-3">
184 <div className="flex flex-wrap items-baseline justify-between gap-2">
185 <span className="text-sm font-medium">{label}</span>
186 <span className="tabular text-sm">
187 {usd(used)} <span className="text-faint">of {cap > 0 ? usd(cap) : "no cap"}</span>
188 </span>
189 </div>
190 <div className="mt-2 h-1.5 overflow-hidden rounded-full bg-line" role="meter" aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(percent)} aria-label={label}>
191 <div className={`h-full ${tone}`} style={{ width: `${percent}%` }} />
192 </div>
193 <p className="mt-1.5 text-xs text-muted">{hint}</p>
194 </div>
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running195 );
196}
197
198/**
199 * Where the money went, as a short statement: usage sold and running g1t
200 * (each against what paid for it), what g1t gave away on purpose (a budget,
201 * never a loss), and who was paid.
202 */
203function Statement({ report, floor, range, proposals }: { report: CostsReport; floor: number; range: number; proposals: number }) {
204 const o = report.overall;
205 // Reports from before the statement have only the totals.
206 const given = o.givenMicros ?? 0;
207 const usageCost = o.usageCostMicros ?? o.costMicros - given;
Costs: the plan's included usage counts as paid for the usage it covered, out of what plans leave for running g1t; the run button shows it is running with CSS alone (sudo ships no JavaScript)208 const included = o.includedMicros ?? 0;
209 const usageIn = o.usageMicros + included;
210 const usageMargin = o.usageMarginMicros ?? usageIn - usageCost;
sudo: a billing reset runs the costs analysis again so every figure is fresh; every submit button shows it is working (CSS only); no margin percentage on less than a cent sold211 // Under a cent sold, a percentage says nothing (a few micros against none).
212 const soldSomething = usageIn >= 10_000;
213 const usagePercent = soldSomething && o.usageMarginPercent !== undefined ? o.usageMarginPercent : null;
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running214 const running = o.runningCostMicros ?? 0;
215 const unmapped = o.unmappedCostMicros ?? 0;
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly216 // Cloudflare's subscriptions are not on the usage bill: a month's, over the range.
217 const subscriptions = subscriptionsOver(report.caps.fixedMonthlyMicros, range);
218 const paid = whoPaid(o, subscriptions);
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running219 const moneyIn = o.usageMicros + o.plansMicros;
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly220 const spent = paid.totalMicros;
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running221 const net = moneyIn - spent;
222 const givenParts = [
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging223 ["100% discounts", o.givenCompedMicros ?? 0],
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running224 ["free use", o.givenFreeMicros ?? 0],
225 ["trial", o.givenTrialMicros ?? 0],
226 ["open-source pool", o.givenPoolMicros ?? 0],
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging227 ["partial discounts", o.givenDiscountMicros ?? 0],
228 ["promotional credit", o.givenCreditPromotionalMicros ?? 0],
229 ["goodwill credit", o.givenCreditGoodwillMicros ?? 0],
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97230 ["testing resets", o.givenResetMicros ?? 0],
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running231 ].filter(([, micros]) => (micros as number) > 0) as [string, number][];
232 const rows: { title: string; note: string; in: number | null; cost: number; result: number | null; tone?: "danger" | "warn" | "muted" }[] = [
233 {
234 title: "Usage sold",
Costs: the plan's included usage counts as paid for the usage it covered, out of what plans leave for running g1t; the run button shows it is running with CSS alone (sudo ships no JavaScript)235 note:
236 included > 0
sudo: the costs statement reads to the cent237 ? `What workspaces paid for usage (${usd(o.usageMicros, { cents: true })}) and their plan's included usage (${usd(included, { cents: true })}), against what it cost`
Costs: the plan's included usage counts as paid for the usage it covered, out of what plans leave for running g1t; the run button shows it is running with CSS alone (sudo ships no JavaScript)238 : "What workspaces paid for usage, against what that usage cost",
239 in: usageIn,
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running240 cost: usageCost,
241 result: usageMargin,
242 tone: usageMargin < 0 ? "danger" : undefined,
243 },
244 {
245 title: "Running g1t",
Costs: the plan's included usage counts as paid for the usage it covered, out of what plans leave for running g1t; the run button shows it is running with CSS alone (sudo ships no JavaScript)246 note:
247 included > 0
sudo: the costs statement reads to the cent248 ? `Plans (${usd(o.plansMicros, { cents: true })}) less the included usage they paid for, against Workers, D1, KV, Queues and the rest`
Costs: the plan's included usage counts as paid for the usage it covered, out of what plans leave for running g1t; the run button shows it is running with CSS alone (sudo ships no JavaScript)249 : "Plans, against Workers, D1, KV, Queues and the rest of the platform",
250 in: o.plansMicros - included,
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running251 cost: running,
Costs: the plan's included usage counts as paid for the usage it covered, out of what plans leave for running g1t; the run button shows it is running with CSS alone (sudo ships no JavaScript)252 result: o.plansMicros - included - running,
253 tone: o.plansMicros - included - running < 0 ? "warn" : undefined,
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running254 },
255 {
256 title: "Cloudflare subscriptions",
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing257 note:
258 report.caps.fixedSource === "cloudflare"
259 ? `Fixed, as Cloudflare lists them${(report.caps.fixedItems ?? []).length > 0 ? ` (${(report.caps.fixedItems ?? []).map((i) => i.name).join(", ")})` : ""}; not on the usage bill`
260 : "Fixed, an estimate (CLOUDFLARE_FIXED_MONTHLY_MICROS) until Cloudflare's list is read; not on the usage bill",
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running261 in: null,
262 cost: subscriptions,
263 result: -subscriptions,
264 tone: "muted",
265 },
266 ...(unmapped > 0
267 ? [{ title: "Not mapped", note: "Billed by Cloudflare, charged for by nothing yet", in: null, cost: unmapped, result: -unmapped, tone: "danger" as const }]
268 : []),
269 {
270 title: "Given away",
sudo: the costs statement reads to the cent271 note: givenParts.length > 0 ? givenParts.map(([why, micros]) => `${why} ${usd(micros, { cents: true })}`).join(" · ") : "Nothing this range",
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running272 in: null,
273 cost: given,
274 result: null,
275 tone: "muted",
276 },
277 ];
278 const resultClass = (tone?: string) => (tone === "danger" ? "text-danger" : tone === "warn" ? "text-warn" : tone === "muted" ? "text-muted" : "text-fg");
279 return (
280 <>
281 <div className="mt-5 grid grid-cols-2 gap-3 lg:grid-cols-4">
282 <Stat
283 label="Margin on usage sold"
284 value={percentLabel(usagePercent)}
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly285 hint={
286 soldSomething
287 ? `Of the price: ${usd(usageIn, { cents: true })} paid for usage that cost ${usd(usageCost, { cents: true })}`
288 : "No usage sold in this range"
289 }
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running290 tone={marginTone(usagePercent, floor)}
291 />
292 <Stat
293 label="Given away on purpose"
sudo: the costs statement reads to the cent294 value={usd(given, { cents: true })}
295 hint={givenParts.length > 0 ? givenParts.map(([why, micros]) => `${usd(micros, { cents: true })} ${why}`).join(", ") : "Nothing given this range"}
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running296 />
297 <Stat
298 label="Who g1t paid"
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly299 value={usd(paid.totalMicros, { cents: true })}
300 hint={`Cloudflare's usage ${usd(paid.cloudflareMicros, { cents: true })} and subscriptions ${usd(paid.subscriptionsMicros, { cents: true })}, model providers ${usd(paid.modelsMicros, { cents: true })}; the cost in All in`}
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running301 />
302 <Stat
303 label="Proposals waiting"
304 value={String(proposals)}
Costs: Cloudflare's subscriptions read from Cloudflare each day, the estimate only until then; sudo's costs split into Costs & margin and Bill & pricing305 hint={
306 <>
307 <Link to={costsHref("bill", range) + "#proposals"} className="underline underline-offset-2">
308 On Bill &amp; pricing
309 </Link>
310 {report.fetchedAt ? (
311 <>
312 {" "}
313 · bill read <When at={report.fetchedAt} time />
314 </>
315 ) : (
316 " · the bill has not been read yet"
317 )}
318 </>
319 }
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running320 tone={proposals > 0 ? "warn" : undefined}
321 />
322 </div>
323 <div className="mt-3 overflow-x-auto rounded-lg border border-line bg-surface">
324 <table className="w-full min-w-[36rem] text-sm">
325 <thead>
326 <tr className="border-b border-line text-left text-xs text-muted">
327 <th className="px-4 py-2 font-medium sm:px-5">
328 {report.since} to {report.until}
329 </th>
330 <th className="px-4 py-2 text-right font-medium">Paid in</th>
331 <th className="px-4 py-2 text-right font-medium">Cost</th>
332 <th className="px-4 py-2 text-right font-medium sm:pr-5">Result</th>
333 </tr>
334 </thead>
335 <tbody>
336 {rows.map((row) => (
337 <tr key={row.title} className="border-b border-line">
338 <td className="px-4 py-2.5 sm:px-5">
339 <span className="text-fg">{row.title}</span>
340 <span className="block text-xs text-faint">{row.note}</span>
341 </td>
sudo: the costs statement reads to the cent342 <td className="tabular px-4 py-2.5 text-right">{row.in == null ? <span className="text-faint">—</span> : usd(row.in, { cents: true })}</td>
343 <td className="tabular px-4 py-2.5 text-right">{usd(row.cost, { cents: true })}</td>
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running344 <td className={`tabular px-4 py-2.5 text-right sm:pr-5 ${resultClass(row.tone)}`}>
sudo: the costs statement reads to the cent345 {row.result == null ? "a budget" : usd(row.result, { signed: true, cents: true })}
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running346 </td>
347 </tr>
348 ))}
349 <tr>
350 <td className="px-4 py-2.5 sm:px-5">
351 <span className="font-medium text-fg">All in</span>
352 <span className="block text-xs text-faint">
sudo: the costs statement reads to the cent353 {given > 0 ? `${usd(given, { cents: true })} of the cost was given away on purpose; without it, ${usd(net + given, { signed: true, cents: true })}` : "Everything above"}
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running354 </span>
355 </td>
sudo: the costs statement reads to the cent356 <td className="tabular px-4 py-2.5 text-right font-medium">{usd(moneyIn, { cents: true })}</td>
357 <td className="tabular px-4 py-2.5 text-right font-medium">{usd(spent, { cents: true })}</td>
358 <td className="tabular px-4 py-2.5 text-right font-medium text-fg sm:pr-5">{usd(net, { signed: true, cents: true })}</td>
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running359 </tr>
360 </tbody>
361 </table>
362 </div>
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging363 <p className="mt-2 text-xs text-faint">
364 Credits from g1t, {report.since} to {report.until}: {usd(o.creditsGivenMicros ?? 0, { cents: true })} given, {usd(o.creditsUsedMicros ?? 0, { cents: true })}{" "}
365 spent on usage. What promotional and goodwill credit paid for is given away above, never money in; refunds took{" "}
366 {usd(o.creditsRefundedMicros ?? 0, { cents: true })} off money in on the days they refund.{" "}
367 <Link to="/credits" className="underline underline-offset-2">
368 Every credit
369 </Link>
370 </p>
Merge Stripe Tax, the card fee on card payments, and one free workspace per person371 <dl className="mt-3 grid grid-cols-2 gap-3 rounded-lg border border-line bg-surface px-4 py-3 text-sm sm:px-5">
372 <div>
373 <dt className="text-xs text-muted">Tax collected</dt>
374 <dd className="tabular text-fg">{usd(o.taxCollectedMicros ?? 0, { cents: true })}</dd>
375 <dd className="text-xs text-faint">Owed to tax authorities; never in money in or margin. Filed from Stripe Tax.</dd>
376 </div>
377 <div>
378 <dt className="text-xs text-muted">Card fees passed on</dt>
379 <dd className="tabular text-fg">{usd(o.cardFeesMicros ?? 0, { cents: true })}</dd>
380 <dd className="text-xs text-faint">Paid Stripe&apos;s card fees; not revenue either.</dd>
381 </div>
382 </dl>
Costs: a statement that keeps usage sold, running g1t, subscriptions and what was given away (comped, free use, trial, pool) apart, and says who was paid; free use carries its own cost; the run button says it is running383 </>
384 );
385}
386
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly387function SpendSection({ caps, range, error }: { caps: CostsReport["caps"]; range: number; error: string | null }) {
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays388 const { rows, totalMicros } = spendRows(caps);
389 const net = caps.revenueMicros - totalMicros;
390 return (
391 <Section
392 className="mt-6"
393 id="spend"
394 title="g1t's own spend"
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly395 description="What g1t pays for itself this calendar month, today included: accounts on a 100% discount, the trial and open-source pools, free workspaces' overruns, and usage charged without real money behind it. Each is what the work cost g1t, never its price, counted as each charge settled: the model providers' cost, and the price book's cost of sandboxes and builds. Two caps hold it: each 100%-discount account's monthly budget, and a daily breaker on all of it that pauses new hosted-model agent runs g1t would pay for."
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays396 >
397 <div className="grid gap-3 lg:grid-cols-2">
398 <CapMeter
399 label={`Today, ${caps.day} (UTC)`}
400 used={caps.todayMicros}
401 cap={caps.dailyCapMicros}
402 hint={
403 caps.tripped ? (
404 <span className="text-danger">
405 Breaker open{caps.trippedAt ? <> since <When at={caps.trippedAt} time /></> : null}: new hosted-model runs g1t pays for wait until 00:00 UTC.
406 </span>
407 ) : caps.liftedBy ? (
408 <>
409 Lifted for today by {caps.liftedBy}
410 {caps.liftNote ? `: “${caps.liftNote}”` : ""}.
411 </>
412 ) : (
413 "Paying workspaces on a live card are never paused. PLATFORM_DAILY_SPEND_CAP_MICROS."
414 )
415 }
416 />
417 {caps.comped.map((b) => (
418 <CapMeter
419 key={b.account}
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging420 label={`${b.name}, ${caps.month} (100% discount)`}
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays421 used={b.usedMicros}
422 cap={b.ceilingMicros}
423 hint={
424 <>
425 {b.ceilingMicros > 0 && b.usedMicros >= b.ceilingMicros ? (
426 <span className="text-danger">Used up: new work on it is refused. </span>
427 ) : null}
428 {b.defaultCeiling ? "The default budget (COMPED_MONTHLY_CEILING_MICROS)" : "Its own budget, in its terms"}. Raise it on{" "}
429 <Link to={`/workspaces/${encodeURIComponent(b.name)}#billing`} className="underline underline-offset-2">
430 its account
431 </Link>
432 : Terms, Limit.
433 </>
434 }
435 />
436 ))}
437 </div>
438 {(caps.tripped || error) && (
439 <form method="post" action="#spend" className="mt-4 flex flex-col gap-2 sm:flex-row sm:items-end">
440 <input type="hidden" name="intent" value="lift" />
441 <Field label="Why lift it" hint="Recorded in the audit log.">
442 <Input name="note" required minLength={5} maxLength={500} placeholder="e.g. Launch day; watching it" className="sm:min-w-[24rem]" />
443 </Field>
444 <Button type="submit" variant="danger">
445 Lift for today
446 </Button>
447 </form>
448 )}
449 {error && (
450 <div className="mt-3">
451 <Notice tone="error">{error}</Notice>
452 </div>
453 )}
454 <div className="-mx-4 mt-5 overflow-x-auto sm:-mx-5">
455 <table className="w-full min-w-[34rem] text-sm">
456 <thead>
457 <tr className="border-b border-line text-left text-xs text-muted">
458 <th className="px-4 py-2 font-medium sm:px-5">{caps.month}, so far</th>
459 <th className="px-4 py-2 text-right font-medium sm:pr-5">g1t paid</th>
460 </tr>
461 </thead>
462 <tbody>
463 {rows.map((row) => (
464 <tr key={row.key} className="border-b border-line align-top">
465 <td className="px-4 py-2.5 sm:px-5">
466 {row.title}
467 <span className="block text-xs text-faint">{row.note}</span>
468 </td>
469 <td className="tabular px-4 py-2.5 text-right sm:pr-5">{usd(row.micros)}</td>
470 </tr>
471 ))}
472 <tr className="border-b border-line font-medium">
473 <td className="px-4 py-2.5 sm:px-5">All of it</td>
474 <td className="tabular px-4 py-2.5 text-right sm:pr-5">{usd(totalMicros)}</td>
475 </tr>
476 <tr className="border-b border-line">
477 <td className="px-4 py-2.5 sm:px-5">
478 Money in
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly479 <span className="block text-xs text-faint">Usage paid for with real money and the plan, as last reconciled</span>
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays480 </td>
481 <td className="tabular px-4 py-2.5 text-right sm:pr-5">{usd(caps.revenueMicros)}</td>
482 </tr>
483 <tr>
484 <td className="px-4 py-2.5 sm:px-5">Money in less what g1t paid</td>
485 <td className={`tabular px-4 py-2.5 text-right sm:pr-5 ${net < 0 ? "text-danger" : "text-fg-soft"}`}>{usd(net, { signed: true })}</td>
486 </tr>
487 </tbody>
488 </table>
489 </div>
Costs & margin: one total for who g1t paid, own spend explained, rates and replaced rises said plainly490 <p className="mt-3 text-xs text-muted">
491 Why this differs from the statement above: this is {caps.month} so far, the statement the last {range} days. The statement takes Cloudflare&apos;s bill as the
492 cost of what Cloudflare runs, so sandboxes and builds inside Cloudflare&apos;s included usage cost nothing there, and here what the price book says they
493 cost. Here are Cloudflare&apos;s subscriptions for the whole month, there for the range.
494 {(caps.resetMicros ?? 0) > 0 && (
495 <>
496 {" "}
497 And {usd(caps.resetMicros ?? 0, { cents: true })} of this was spent on {(caps.resetWorkspaces ?? []).join(", ")} before a testing reset wiped
498 {(caps.resetWorkspaces ?? []).length === 1 ? " its" : " their"} billing: still g1t&apos;s spend, but the statement has it only where the reset kept
499 it, as given away.
500 </>
501 )}
502 </p>
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays503 </Section>
504 );
505}
506

This file's history is long; its oldest lines are credited to the oldest commit read.