Documentation
¶
Overview ¶
Package weekly builds the report that says what moved — and, more often, that nothing did.
The premium page promises "the repository that cost 3× its usual week", and the whole difficulty is in the word *usual*. Comparing this week with last week gives a ratio, not a finding: a repository that cost $2 and then $6 has tripled and means nothing. So "usual" here is the median of the four weeks before this one, and a mover is only reported when it also clears an absolute floor in dollars. Below that the report says the week was ordinary, which is true and worth saying (ADR-024).
This matters more than it would on the dashboard. A reader looking at a screen can click into a figure that surprises them; a reader holding a message cannot. A confident wrong headline in a weekly message is a claim they have no way to check, which is the reason `caprock report` already refuses to publish a breakdown whose linkage is too weak.
Index ¶
Constants ¶
const BaselineWeeks = 4
BaselineWeeks is how many weeks "usual" is measured over.
Four is a compromise: long enough that one unusual week does not become the baseline, short enough to follow someone whose work genuinely changed a month ago. The median of the four is used rather than the mean, because one runaway week would drag a mean up and hide the next one.
const MinMoveUSD = 10.0
MinMoveUSD is the smallest change worth calling a movement.
Ten dollars, and the first draft had it at three — which the tests caught immediately. A repository going from $2 to $6 clears a $3 floor and is exactly the finding this floor exists to suppress: it is three times its usual week and it is nothing. The floor has to be large enough that the change is worth a person's attention on its own, before the multiple is even considered, because a report that cries wolf is one people stop opening — and that costs more than missing a mover.
const TelegramAPI = "https://api.telegram.org"
TelegramAPI is the only host this package ever contacts.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Day ¶
type Day struct {
Day string // YYYY-MM-DD
Project string
Model string
CostUSD float64
Tokens int64
}
Day is one row of daily_stats: a day, a project, a model, and what it cost.
type Move ¶
type Move struct {
Project string `json:"project"`
ThisUSD float64 `json:"this_usd"`
// UsualUSD is the median of the baseline weeks, which is what "3× its usual
// week" is measured against — not last week.
UsualUSD float64 `json:"usual_usd"`
// Multiple is ThisUSD / UsualUSD. Zero when the project had no baseline at
// all, which is reported as "new" rather than as an infinite multiple.
Multiple float64 `json:"multiple"`
New bool `json:"new"`
}
Move is one repository whose week departed from its usual.
type ProjectWeek ¶
type ProjectWeek struct {
Project string `json:"project"`
CostUSD float64 `json:"cost_usd"`
Tokens int64 `json:"tokens"`
}
ProjectWeek is one repository's week.
type Report ¶
type Report struct {
WeekStart time.Time `json:"week_start"`
WeekEnd time.Time `json:"week_end"`
CostUSD float64 `json:"cost_usd"`
// PriorUSD is the median week of the baseline, for the one line that says
// whether the week as a whole was ordinary.
PriorUSD float64 `json:"prior_usd"`
Tokens int64 `json:"tokens"`
// Movers are ranked by how far they departed, biggest first. Empty is the
// normal case and is not a failure.
Movers []Move `json:"movers"`
// Projects is the week's spend per repository, biggest first — the part
// that is true whether or not anything moved.
Projects []ProjectWeek `json:"projects"`
// Quiet says the week produced no reportable movement, so the message can
// say so plainly instead of listing nothing.
Quiet bool `json:"quiet"`
// NoData means the week has no priced activity at all — the machine was off,
// or the daemon was. Reporting a 100% drop for a week nobody worked would be
// a lie the reader cannot check.
NoData bool `json:"no_data"`
}
Report is a week, and what is worth saying about it.
type Sender ¶
Sender delivers a finished report. The zero value is usable.
This is the product's first *background* outbound call — the release check and Gemini both fire because a person did something in that moment. What keeps it inside rule 4 is what it carries and what turns it on: figures the user already sees on their own dashboard, never a prompt, a reply, a tool result or a file path, and only once they have configured a bot of their own. With no token there is no timer and nothing to switch off.