Documentation
¶
Overview ¶
Package morning is the morning report: one push a day, at a fixed local time, saying what happened while the owner was away, and the page it opens (docs/features.md#morning-report). This file is the schedule; report.go is the report's shape, its quiet-day rule and its push text; store.go is the one row per owner per day.
🔴 READ-ONLY. Nothing here, and nothing that calls it, acts on a session, an ask or a task: the report reads muster's own rows and says what they hold. Its open questions are answered on its page through the Asks queue's own answer route, by the owner's tap, exactly as on /attention.
🔴 THE TIME IS A SERVER SETTING (an operator decision): muster stores no time zone per owner yet (docs/design/check-ins.md, "Time zones"), so every owner's report is due at the same wall-clock time in one zone.
Index ¶
- Constants
- func PushBody(questions, merged, stuck int) string
- type Body
- type ChiefUsage
- type CostUsage
- type Day
- type Done
- type Gap
- type PG
- func (p *PG) ClaimPush(ctx context.Context, date string, at time.Time) (bool, error)
- func (p *PG) Get(ctx context.Context, date string) (Row, bool, error)
- func (p *PG) Insert(ctx context.Context, r Row) (bool, error)
- func (p *PG) Latest(ctx context.Context) (Row, bool, error)
- func (p *PG) Owners(ctx context.Context) ([]int64, error)
- type PlanAccount
- type PlanUsage
- type Report
- type Row
- type Schedule
- type Store
- type Stuck
- type Usage
Constants ¶
const ( DoneMerged = "merged" // a pull request merged // DoneTaskChanged: a task that is complete and was last changed in the // window. ⚠ muster keeps no time a task was COMPLETED: any change to a // complete task (a tag, a synced snapshot) moves updated_at, so the page // says "changed overnight", never "finished", and such a line does not by // itself make a day loud. DoneTaskChanged = "task" )
The kinds of a Done line.
const ( StuckIdle = "idle" // a session stopped with nothing running StuckError = "error" // a session stopped on an error (a usage limit, an API error) StuckFailed = "failed" // a dispatched agent failed )
The kinds of a Stuck line.
const CatchUp = 2 * time.Hour
CatchUp is how late a report may still go out: a server that was down at the report time and comes back within this sends that day's report late; past it the day is skipped, never backfilled (the check-ins design's catch-up rule, docs/design/check-ins.md "The scheduler").
const PushTag = "morning-report"
PushTag is the push's tag: a newer report replaces the older one on the phone.
const PushTitle = "While you were away"
PushTitle is the push's title.
const ReportHour = 8
ReportHour is the report's time of day, 08:00 (an operator decision). Only its zone is a setting (MUSTER_MORNING_REPORT_TZ).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Body ¶
type Body struct {
Done []Done `json:"done"`
Stuck []Stuck `json:"stuck"`
Usage Usage `json:"usage"`
// Gaps are the plain sentences saying what could not be read ("Merged
// pull requests could not be checked just now.").
Gaps []Gap `json:"gaps,omitempty"`
}
Body is what a report's row keeps of it: the lines that were true in its window, as the job read them. The open questions are not kept — the page reads them live, as the real asks, so an answered one is gone.
type ChiefUsage ¶
ChiefUsage is the chief's own work in the window: turns and how long they ran (chief_turn_usage).
type CostUsage ¶
CostUsage is what the chief's work cost, where muster knows: its OpenRouter sessions' spend (chief_session_llm_usage). That spend is booked per UTC DAY, so the report says the spend of Day, the last WHOLE UTC day before its report time: the day the report time falls in is still running (08:00 in Chicago is 13:00 or 14:00 UTC), and the next report counts it, so consecutive reports each count one day, none twice. Claude plans carry no cost.
type Day ¶
type Day struct {
// Date is the local date, "2006-01-02": the report's key and its URL.
Date string
// Slot is the instant the report is due (UTC).
Slot time.Time
// Since is the previous local day's slot: the window's start.
Since time.Time
}
Day is one day's report: its local date, the instant it is due, and the window it covers — from the previous local day's report time to this one.
🔴 THE WINDOW IS TWO WALL-CLOCK TIMES, NOT "SLOT MINUS 24 HOURS": across a daylight-saving change the night is 23 or 25 hours long, and a fixed 24h would drop, or count twice, the hour the clocks moved. Each window starts exactly where the previous day's ended, so no event is in two reports and none falls between them.
type Done ¶
type Done struct {
Kind string
// Label is the line's text: a pull request's title, a task's title.
Label string
// Ref is a pull request's owner/repo#n ("" for a task): kept for the
// link, never drawn as the line's text.
Ref string `json:",omitempty"`
Href string
At time.Time
}
Done is one thing that got done (or, for a task, changed).
type Gap ¶
type Gap struct {
Text string `json:"text"`
}
Gap is one thing the report could not read: its plain sentence. The page names the setting behind it, for an admin.
type PG ¶
type PG struct {
// contains filtered or unexported fields
}
PG is Store on Postgres.
type PlanAccount ¶
type PlanAccount struct {
// FiveHour and Week are the percent used (nil: not read).
FiveHour, Week *float64
ReadAt time.Time
}
PlanAccount is one account's reading. Its configured name is not kept: the page calls it "Claude plan 1", "Claude plan 2", in the accounts' order.
type PlanUsage ¶
type PlanUsage struct {
Tracked bool
Off string
Accounts []PlanAccount
}
PlanUsage is the AI plan's usage: each Claude account's latest reading. 🔴 A LATEST READING, NEVER A NIGHT'S SUM: muster keeps one reading per account (cc_account_usage), overwritten on each poll, so the page says when it was read and never claims an overnight figure it does not have.
type Report ¶
type Report struct {
Since, Until time.Time
// Questions is how many questions wait on the owner now (the Asks
// queue's open questions); NewQuestions how many of them were asked in
// the window. The page lists them live, so only the counts are kept.
Questions, NewQuestions int
// Unchecked: whether a pull request merged could not be settled — a
// state GitHub did not answer, or more recent pull requests than one
// report reads. Such a day is never quiet: a merge may be hiding there.
Unchecked bool
Body
}
Report is one owner's morning report as the job builds it: the window [Since, Until), the open questions counted, and the Body it stores. Every field is muster's own rows; nothing here is a model's words.
func (Report) Quiet ¶
Quiet reports a day on which nothing happened: no question asked in the window still waits, no pull request merged, nothing got stuck in the window, and every pull request was checked. A quiet day sends no push (operator decision: "send it only on days when something happened").
🔴 WHAT NEVER MAKES A DAY LOUD BY ITSELF: usage; a question asked before the window (owner asks wait up to 24 h, so yesterday's would push every morning); a session stuck since before the window (or a session left stopped would push forever); and a complete task that only CHANGED in the window (DoneTaskChanged: a tag or a sync moves it). All of them are still listed on the page.
type Row ¶
type Row struct {
Date string
Since, Until time.Time
Quiet bool
Questions int
Body Body
CreatedAt time.Time
PushedAt time.Time // zero: no push
}
Row is one day's report as stored.
type Schedule ¶
Schedule is when the report is due: Hour:Minute every day in Loc.
func (Schedule) Due ¶
Due is the report due at now: today's (in Loc) once its slot has passed and for CatchUp after it; false before the slot and after the catch-up.
type Store ¶
type Store interface {
// Insert records day's report for the principal. 🔴 ONE PER OWNER PER
// DAY: false (and nothing written) when the day already has one — the
// caller then builds and sends nothing.
Insert(ctx context.Context, r Row) (bool, error)
// ClaimPush marks date's report pushed, once: true for the one caller
// that moved pushed_at from NULL, false for every other (already pushed,
// a quiet day, or no such report). Claimed BEFORE the send, so a send is
// at most once.
ClaimPush(ctx context.Context, date string, at time.Time) (bool, error)
// Get is the principal's report of date; false when there is none.
Get(ctx context.Context, date string) (Row, bool, error)
// Latest is the principal's newest report; false when there is none.
Latest(ctx context.Context) (Row, bool, error)
// Owners is who gets a report: every enabled person, never a team (a
// team's sessions are its members' to read) and never a disabled
// account. Read under the system scope.
Owners(ctx context.Context) ([]int64, error)
}
Store is the reports.
type Stuck ¶
type Stuck struct {
Kind string
Name string
// Why is the plain reason ("idle, nothing running", "stopped on an error").
Why string
Href string
Since time.Time
}
Stuck is one thing that is stuck.
type Usage ¶
type Usage struct {
Chief ChiefUsage
Plan PlanUsage
Cost CostUsage
}
Usage is the window's usage and cost. A part whose source is off says so in Off, a plain sentence; the setting behind it is the page's to name (an admin's ⓘ), never stored.