Documentation
¶
Overview ¶
Package api is atrium's human-facing surface: the JSON endpoints and SSE stream that the TUI, the SPA, and any future app all consume.
This listener is separate from the agent-facing one. When the store halts, the agent listener closes so runners park on connection-refused and stop burning tokens, while this one stays up to explain what broke.
Index ¶
- Constants
- Variables
- func ApplyInputLag(st *store.Store)
- func BoardID(fsys fs.FS) string
- func ContextCycleOn(t *store.Task) bool
- func ContextLimitFor(st *store.Store, t *store.Task) (int, string)
- func EmbeddedBoard() fs.FS
- func ForgetTranscripts(cwd string) error
- func IsClaudeHarness(h *store.Harness) bool
- func KnownSkin(name string) bool
- func LatestSession(cwd string) string
- func LookPath(cmd string) string
- func MoveWorktree(from, to string) error
- func NotOnRoom(id, room string) error
- func ProjectDirFor(cwd string) (string, error)
- func RunnerCeilingK(t *store.Task) int
- func RunnerFound(h *store.Harness) string
- func ScrollbackBytes(st *store.Store) int
- func SessionExists(cwd, id string) bool
- func SlugTheme(name string) string
- func TerminalMinCols(st *store.Store) int
- func TranscriptPath(cwd, id string) string
- func ViewImageType(ext string) (string, bool)
- type CardColors
- type ChangesError
- type ContextLimit
- type DocShareError
- type DocShareRequest
- type PRClaimAsk
- type PRClaimReply
- type PRFinding
- type PRFindingCounts
- type PRFindingWalk
- type PRRunner
- type PRWalkCounts
- type Server
- func (s *Server) Broadcast(kind string, payload any)
- func (s *Server) CardColors() CardColors
- func (s *Server) Close()
- func (s *Server) ContainedOrOpen(card, want string) (string, error)
- func (s *Server) Handler() http.Handler
- func (s *Server) PreviewPort(port int) error
- func (s *Server) PublishPR(id string)
- func (s *Server) PublishTask(t *store.Task)
- func (s *Server) ReconcilePRClaims()
- func (s *Server) SkinOrDefault() string
- func (s *Server) Sweep(ctx context.Context) *sweepReport
- type TurnFinding
- type TurnLimitReport
- type UsageWeekReset
Constants ¶
const ( CloseKeep = "keep" CloseStash = "stash" CloseDelete = "delete" )
Close answers to an asked worktree.
const ( LimitFromCard = "card" LimitFromHub = "hub" LimitFromDefault = "default" // LimitFromRunner is a limit the runner's own compaction point cut down. See RunnerCeilingK. LimitFromRunner = "runner" )
The layers a context limit can come from, named on the row so the board can say which.
const ( SettingScrollbackMB = "scrollback_mb" SettingScrollbackLines = "scrollback_lines" )
How much of a session you can scroll back through.
TWO NUMBERS, because there are two buffers and whichever runs out first is what you get. Not "the smaller of the two": they are in different units and there is no comparing them without guessing a line length.
The daemon keeps the last N bytes of every supervised runner's output and writes the whole lot down the socket when a browser attaches. Nothing older than that buffer can ever reach the page, whatever the page is willing to hold, so this is the one that decides whether scrolling up finds anything.
The browser then keeps the last N LINES of what it was sent. Past that xterm drops from the top, so a generous daemon with a small browser buffer gives a short scrollback that cost a lot to produce.
Sized in bytes on one side and lines on the other because that is what each end actually counts, and converting between them means guessing a line length. A progress bar redrawing itself is one line and can be megabytes.
const ClosedTag = "atrium:closed"
ClosedTag is on a card the operator closed. The terminals tab does not list a card that carries it and has no session, even with show stopped on: a close freed its folder, so there is nothing to resume.
const DefaultPastePreamble = "check out the image here: "
DefaultPastePreamble reads as an instruction rather than as a fragment.
const DefaultSkin = "harbour"
DefaultSkin is the palette in `:root`, which is the one the board came with.
Named rather than empty so the picker has something to select. An empty setting means the same thing and is what a board that has never been asked reports, which is why `SkinOrDefault` treats them as one.
const OverrideColdHandoff = "cold_handoff"
OverrideColdHandoff is the card's own switch for the cold handoff: "off" stops atrium handing it off as its cache goes cold. Empty means the room's switch decides.
const OverrideContextCycle = "context_cycle"
OverrideContextCycle is the card's own switch: "off" stops atrium cycling it. Empty means on.
const OverrideContextLimitK = "context_limit_k"
OverrideContextLimitK is the key of a card's own context limit in its overrides, in thousands of tokens. Empty means none: the hub's limit for its harness applies.
const PRArchiveCap int64 = 64 << 20
PRArchiveCap bounds an archive, both as sent and as unpacked. A test sets `hk.prArchiveCap` on its server so it need not make 64 MiB.
const PRHeaderID = "X-Atrium-PR-ID"
PRHeaderID is the header an export carries the old room's row id in, for the archive call that follows.
const PagePrefixHeader = "X-Atrium-Page-Prefix"
PagePrefixHeader is the path the hub served the page under, `/room/<room>/<card>/files/`, so a root-relative link in the page can be put back under it.
const ParentChanged = "parent-changed"
ParentChanged is the `by` of the `notified` event that records an operator moving a card under another card.
const PastePreambleNone = "none"
PastePreambleNone is how "no preamble at all" is stored.
A word rather than an empty string, because an empty string is what a setting that has never been written reads as, and "never chose" and "chose nothing" have to be two different answers or the default can never be turned off. Nobody types this: the board writes it when the box is unticked.
const RealPathHeader = "X-Atrium-Real-Path"
RealPathHeader carries a download's resolved path, path-escaped: relative to the card, or absolute outside it.
const ReviewTag = "atrium:review"
ReviewTag is the tag of a card launched with kind review (link.ReviewTag, daemon.ReviewTag).
const SettingBoardSkin = "board_skin"
const SettingBrowseRoots = "browse_roots"
Where the directory picker may look.
A BOUND EXISTS BECAUSE THE BOARD CAN BE PUBLISHED. A share terminates on this machine, so every request over one presents as `127.0.0.1` and nothing can be decided by source address. Unbounded, `GET /v1/browse` over a share is an unauthenticated recursive directory listing of the whole machine. It enumerates rather than discloses, since nothing reads file contents through it, which is why this is a bound rather than an incident.
Everything outside the root set is refused the same way whether or not it exists. The default keeps the picker useful without being the machine:
- the home directory
- every directory a card, fixture, source or harness already names, which are directories atrium has already been pointed at
`SettingBrowseRoots` widens it for anyone whose work is somewhere else. It is a setting rather than a flag because it is a fact about one machine's layout, and it is a list rather than a boolean because "off" would mean the old behaviour and there is no good reason to keep that reachable.
const SettingCardColors = cardcolors.Setting
SettingCardColors and CardColors live in internal/cardcolors, shared with the hub.
const SettingCardPorts = "ports.card_range"
SettingCardPorts is the room's card port range, "lo-hi".
const SettingEditor = "editor_command"
SettingEditor names the command that opens a file. Empty means this endpoint is off, which is the default and is the state that requires no trust.
const SettingInputLag = "input_lag_log"
SettingInputLag is whether this room logs terminal input lag, `on` or `off`. Empty means never set, which is off. See internal/inputlag.
A SETTING AND NOT ONLY A VARIABLE, because the variable is read once at start and finding a lag means switching the logging on while the lag is happening. A restart is the one thing that makes the lag go away for a while. The gear writes this through the hub, which keeps its own copy and passes the write to every room, so one checkbox times the browser, the hub and the room together.
const SettingLoginCommand = "login_command"
SettingLoginCommand is stored on the room it logs in, and empty means the board's default ssh line.
const SettingOpenExternalAnywhere = "open_external_anywhere"
SettingOpenExternalAnywhere is the stored switch of the removed open externally. Only settings reads it.
const SettingOpenPaths = "open_paths"
SettingOpenPaths is the folders the board may open files from besides the card's own and the atrium paths. One absolute directory per line, empty by default.
const SettingPasteKeep = "paste_keep"
SettingPasteKeep decides whether a pasted file is kept.
Two honest answers and no third one:
keep the card's own `.atrium/incoming`, where it stays. You have the
screenshot tomorrow, and you also have every screenshot you ever
pasted.
scrap a directory beside atrium's own state, emptied on every daemon
start. The path still reaches the agent, the file still works for
as long as the conversation does, and your repository does not
accumulate a folder of pictures you looked at once.
There is no option that hands the bytes straight to the model. A pseudo terminal carries input characters, and an image is not one. Claude Code gets a pasted image by reading the clipboard ITSELF, on its own machine, which is exactly what a browser two machines away cannot do.
const SettingPastePreamble = "paste_preamble"
SettingPastePreamble is what gets typed in front of the path.
A bare path is what a person types when they mean "look at this", and it is not what they say. Nothing is submitted either way: the text and the path are spliced into the line being written, and pressing enter stays yours.
SettingSharedLocation is a second file the daemon writes its address to, for callers running as another account.
The per-user location file is unreadable to anybody but the account the daemon runs as, so a script running as the human cannot find the board and ends up with somebody's profile path hardcoded in it. Naming a directory both accounts can reach fixes that. `%WORKTREE_ROOT%\atrium\daemon.json` is the obvious one, since a caller launching against a worktree already has it.
Empty means only the per-user file is written, which is right for a machine where the daemon and its callers are the same person.
It lives in this package rather than beside `whereami.go` because the settings endpoint is here and the daemon already imports this. See `daemon.sharedLocation`, which reads it.
const SettingShellCommand = "shell_command"
SettingShellCommand names the shell a pane opens, and empty means the one `internal/shellpick` finds.
HERE FOR THE SAME REASON `SettingSharedLocation` is: the settings endpoint is in this package and the daemon already imports it. It lived in `daemon/shell.go` beside the code that reads it, which is the tidier place and is why it never reached the settings surface. It was documented, carried by the config export, and settable only by editing the database.
That mattered more than an ordinary gap, because this setting was the WORKAROUND for a shell that always came up as cmd. The escape hatch was unreachable by exactly the person who needed it.
const SettingTerminal = "terminal_command"
SettingTerminal names the command that opens a directory in a terminal window. Empty means this endpoint is off, which is the default and is the state that requires no trust.
const SettingTerminalMinCols = "terminal_min_cols"
The narrowest a runner's terminal may go.
Claude Code wraps its own lines and reprints its whole conversation on every width change without clearing the scrollback, so every width a pty passes through leaves a copy of the conversation at that width for good. A narrow width leaves a narrow band nobody can read. The floor bounds the damage: the pty never goes under it, and a narrower window scrolls sideways instead.
RUNNERS ONLY. A shell does not reprint, so narrow does no harm there.
const SettingUsageCacheReads = "usage_cache_reads"
SettingUsageCacheReads is `on` when the usage tab draws cache reads. Unset is off.
const SettingUsageWeekReset = "usage_week_reset"
SettingUsageWeekReset holds the JSON of a UsageWeekReset. Unset is the default.
const SettingWorktreeHooks = "worktree_hooks_dir"
SettingWorktreeHooks is the folder of per-repo setup hooks. Unset, it is ~/.atrium/hooks.
Variables ¶
var ActivityOf func(taskID string) any
ActivityOf returns a task's live activity, or nil. Supplied by the daemon, since the activity is held in memory there rather than in the store.
var AutocompactOf func(t *store.Task) any
AutocompactOf returns a card's context limit and runner compaction window, or nil. Supplied by the daemon.
var BudgetOf func(taskID string) any
BudgetOf returns a card's crossed worker budget, or nil. Supplied by the daemon, which holds it in memory.
var BuildID = buildID(embeddedBoard())
BuildID identifies the board this binary carries.
Cache-Control stops the browser reusing a stale copy, and that is a different problem from the one this solves: a page ALREADY OPEN keeps the JavaScript it loaded. A restart replaces what is served and touches nothing that is running, so a popped-out terminal left open for a day is still executing whatever it downloaded when it opened, and a fix shipped since then is simply not there.
That is not hypothetical and not rare, because a popped-out window is long-lived by design. It cost an hour of "the reconnect does not work" for code that reconnected correctly in every window opened afterwards.
So the board is given a way to notice. This goes out with `/v1/health`, the page remembers what it saw first, and a different answer means the thing serving it is not the thing that wrote it. THE WHOLE TREE, not `index.html`. The board used to be one file, so hashing that file was hashing the board. It is now a page that loads `board.css` and two dozen scripts, and almost every change lands in one of those. Hashing only the page would leave the build id identical across a change to any of them, and the reload-on-new-build behaviour above would quietly stop firing for the changes it exists for.
var CardsDir string
CardsDir is where a card's own state goes, <data>/cards. Set by the daemon.
var CheckLeanGateway func(name string) error
CheckLeanGateway is filled by the daemon: it refuses a lean_worker_gateway name the runner's mcp.json does not hold, with the names it does. Nil accepts any name.
var CloseShellFor func(taskID string)
CloseShellFor ends a card's shell, called as the card is deleted.
var CodeID string
CodeID fingerprints the Go this binary was built from, with the board left out. Stamped by the linker (see internal/codeid), empty on a plain build. A hub redeployed with only a board change has a new BuildID and the same CodeID, so the hub can tell a room is running identical code. Reported beside `build` on `/v1/health`.
var ContextSizeOf func(taskID string) any
ContextSizeOf returns a card's context size as the board draws it, or nil. Supplied by the daemon, which reads it from the card's transcript and holds it in memory. Never stored. See docs/runtime/activity-design.md.
var DefaultUsageWeekReset = UsageWeekReset{Day: "sun", Time: "18:00", TZ: "America/New_York"}
DefaultUsageWeekReset is what a board has until it is told otherwise.
var EscalationOf func(taskID string) any
EscalationOf returns an agent-launched card's escalation, or nil. Supplied by the daemon, which works it out on the reaper's tick and holds it in memory. See internal/daemon/a2a.go.
var HasShell func(taskID string) bool
HasShell reports whether this task has a plain shell open beside its runner. Supplied by the daemon for the same reason.
var HeldNoticesOf func(t *store.Task) (int, string)
HeldNoticesOf returns how many held notices a card has not read and when the oldest was held, RFC3339. Supplied by the daemon, which knows which cards hold their notices.
var HeldOf func(taskID string) any
HeldOf returns the room deploy hold a card is held by, or nil. Supplied by the daemon, read from memory.
var IconDir string
IconDir is where card icons live. Set by the daemon, which knows where the rest of atrium's state is. Empty disables upload entirely rather than guessing at a directory.
var IsStarting func(taskID string) bool
IsStarting reports whether atrium is still launching this task's runner. Supplied by the daemon.
var IsSupervised func(taskID string) bool
IsSupervised reports whether atrium owns this task's runner. Supplied by the daemon, since the supervisor lives there.
var KeepaliveOf func(taskID string) any
KeepaliveOf returns a card's cache keep-alive view, or nil. Supplied by the daemon.
var KeepaliveOfTask func(t *store.Task) any
KeepaliveOfTask is KeepaliveOf for a caller that holds the row, so the list does not read it again per card.
var LandedKeptOf func(taskID string) any
LandedKeptOf is why a card whose work landed is still here, or nil. Supplied by the daemon.
var LiveRings func() (runners, shells int)
LiveRings counts runner and shell scrollback rings, supplied by the daemon. Multiply by the per-ring setting to report total capacity; each companion shell allocates its own ring.
var MemOf func(taskID string) int64
MemOf returns what a card's processes hold in bytes, or 0. Supplied by the daemon, from the pty host.
var NewContextOf func(taskID string) any
NewContextOf returns a card's new-context sequence, or nil. Supplied by the daemon, which holds it in memory.
var OutputAtOf func(taskID string) string
OutputAtOf returns when a card's transcript last gained a reply, RFC3339, or "". Supplied by the daemon, which holds it in memory.
OwedOf is how many open owed items a card keeps, when the oldest opened, and whether one is an orphan kept on the worker's own row. See internal/daemon/owed.go.
var RestartWakeOf func(taskID string) any
RestartWakeOf returns a card's after-restart wake, or nil. Supplied by the daemon, which mirrors the store's rows in memory so this is no query per card.
var RunnerCompactAtK func(t *store.Task) int
RunnerCompactAtK says where a card's runner compacts its own conversation, in thousands of tokens, or 0 when it does not or atrium cannot tell. Supplied by the daemon, which can read the machine's Claude Code settings.
var RunningCommit = func() string { return "" }
RunningCommit says which commit this binary was built from, set by the cli package. Reported as `commit` on health.
var ScrapDir string
ScrapDir is where uploads go when they are not being kept. Set by the daemon beside the rest of its state, and emptied at every start.
var Skins = []string{ DefaultSkin, "website", "graphite", "glacier", "abyss", "oxide", "moss", "plum", "ember", "vapor", "sandstone", "noir", "slate", "cobalt", "dusk", "fern", "clay", "mint", "frost", "daylight", "paper", "linen", }
Skins is every skin the board can wear, in the order the picker shows them.
DUPLICATED FROM THE STYLESHEET, and `scripts/check-skins.sh` fails if the two disagree. Parsing CSS out of the embedded board at startup to produce a list of ten strings is more machinery than the thing it produces; the check is what makes the duplication safe.
Order is deliberate: the default first, then the two neutrals, then warm and cool alternating, so scrolling the picker does not read as a hue wheel.
var StartFixture func(id string) error
StartFixture brings one up now rather than at boot. Supplied by the daemon, which owns process spawning.
var TelemetryOf func(taskID string) any
TelemetryOf returns a task's last statusline figure, or nil. Supplied by the daemon for the same reason: it is held in memory there and never stored.
Functions ¶
func ApplyInputLag ¶
ApplyInputLag switches the room's logging to what is stored, for a daemon coming up. A value never written leaves the start-time default alone.
func BoardID ¶
BoardID hashes any board tree the same way `BuildID` hashes the embedded one.
Exported for the same reason: a hub serving files from disk has to be able to tell the page which board it is looking at, or the reload-on-new-build check above compares two different trees and every tab reloads forever.
func ContextCycleOn ¶
ContextCycleOn is whether the card's own switch leaves cycling on.
func ContextLimitFor ¶
ContextLimitFor is the context limit in force for a card, in thousands of tokens, and which layer it came from: the card's own, else the hub's limit for its harness, else the built-in one, and never above the runner's ceiling (then the layer is "runner"). A harness with no entry whose command is claude takes the `claude` entry. Zero means the card has no limit and never cycles.
func EmbeddedBoard ¶
EmbeddedBoard is the board compiled into this binary.
Exported so a HUB can serve these files itself. The hub is the half being restarted while somebody edits CSS, so it holds the board, and the room holds the database. See `internal/link`.
func ForgetTranscripts ¶
ForgetTranscripts deletes the Claude Code project directory for this path. Deleting only the working directory would leave transcripts behind, since Claude Code stores them separately under an encoded path.
func IsClaudeHarness ¶
IsClaudeHarness is whether a runner row runs claude, for the daemon's read of claude's own settings.
func KnownSkin ¶
KnownSkin says whether a name is one atrium ships.
This is checked on the way IN rather than on the way out, and the reason is that an unknown skin fails SILENTLY: the board writes the name onto the body element, no rule matches, and every variable falls through to the default. The result is a setting that saved successfully and did nothing, which is the worst answer available. Refusing at the boundary means the operator gets told.
func LatestSession ¶
LatestSession is the most recently written conversation in a directory, or empty when there is none.
What a fixture actually wants. A fixture says "give me back the terminal I had", and anchoring that to a RECORDED id is wrong twice: the id goes stale the moment anything else starts a session in that directory, and it points at nothing at all once that transcript is deleted. Both fail the same silent way, a fresh conversation with nothing saying why.
Exported because the daemon starts fixtures and this reads Claude Code's files, which is knowledge that belongs on the side that already has it.
func LookPath ¶
LookPath resolves a command the same way launching will, and reports the path so a caller can show what would actually run. Empty when it is not there.
func MoveWorktree ¶
MoveWorktree moves a directory and its Claude Code transcripts. The daemon also calls this after a running session exits. Try renaming first, then fall back to copying for moves across volumes.
func NotOnRoom ¶
NotOnRoom words a card this room does not hold, naming the card and the room, so nobody reads the store's "sql: no rows" and has to guess. Backlog-2 item 63.
func ProjectDirFor ¶
ProjectDirFor is projectDirFor for the daemon's move routes, which read and write a card's transcript folder.
func RunnerCeilingK ¶
RunnerCeilingK is the most a card's limit may be, in thousands of tokens, or 0 for no ceiling. Atrium wants the runner's compaction to land 10 percent AFTER its own cycle point (autocompactK in the daemon), so the ceiling is the runner's compaction point less that 10 percent. A runner that compacts at 220k gives 200k.
func RunnerFound ¶
RunnerFound is where a runner's binary actually is on this machine, or "" when it is not resolvable. An explicit BinPath is checked directly, so a runner installed off the room process PATH still reports as available; otherwise Cmd is resolved against PATH. exec.LookPath validates an absolute path too, so the same "is it really there and runnable" check covers both. See docs/fabric/runner-scoping-design.md.
func ScrollbackBytes ¶
ScrollbackBytes is what the supervisor sizes a runner's ring buffer to.
Read at spawn, so a change applies to the next runner started rather than to one already running. Resizing a live ring means either dropping the scrollback it holds or copying it under the lock every write takes, and neither is worth it for a number changed twice a year.
func SessionExists ¶
SessionExists reports whether a conversation is still on disk.
Asking to resume one that has been deleted is not an error anywhere: the runner starts fresh and says nothing, the card keeps pointing at a file that is gone, and every restart repeats it.
func SlugTheme ¶
SlugTheme turns a scheme's display name into a theme name.
`Campbell Powershell` becomes `campbell-powershell`. Windows Terminal names are free text with capitals, spaces, `+` and `()` in them, and the theme names atrium already uses are lowercase and hyphenated. Converting rather than refusing, because a person who has used `One Half Dark` for six years should not have to rename it to bring it.
func TerminalMinCols ¶
TerminalMinCols is the floor in force. Anything unusable reads as the default, the same rule `readNum` follows.
func TranscriptPath ¶
TranscriptPath is where a Claude session's transcript lives, or "" when it is not there. The keep-alive reads a card's last reply from it.
func ViewImageType ¶
ViewImageType is the content type of an image extension the reader may serve, or false.
Types ¶
type CardColors ¶
type CardColors = cardcolors.Colors
type ChangesError ¶
ChangesError is a refusal the daemon wants answered with a status and a sentence.
func (*ChangesError) Error ¶
func (e *ChangesError) Error() string
type ContextLimit ¶
type ContextLimit struct {
// K is the limit atrium acts on, in thousands of tokens. 0 is none.
K int
// From is the layer K came from: card, hub, default, or runner when the runner's ceiling cut it.
From string
// WantedK and WantedFrom are the limit before the ceiling, when the ceiling cut it. Zero when it did not.
WantedK int
WantedFrom string
// OwnK is the card's own limit as stored, 0 when it has none. Kept even when it is cut or not in force.
OwnK int
// CeilingK is the runner's ceiling, 0 when there is none.
CeilingK int
}
ContextLimit is the limit in force on a card and how it was reached.
func ContextLimitOf ¶
func ContextLimitOf(st *store.Store, t *store.Task) ContextLimit
ContextLimitOf resolves a card's limit: the smaller of the card's own (else the hub's for its harness, else the built-in one) and the runner's ceiling.
type DocShareError ¶
type DocShareError struct {
}
DocShareError is a refusal with the status it should be answered with.
func (*DocShareError) Error ¶
func (e *DocShareError) Error() string
type DocShareRequest ¶
type DocShareRequest struct {
}
DocShareRequest is what the reader sends to share one document: its path in the card, the images it just drew, and how long the link should live.
type PRClaimAsk ¶
type PRClaimAsk struct {
Key string `json:"key"`
URL string `json:"url,omitempty"`
Why string `json:"why,omitempty"`
Head string `json:"head,omitempty"`
Source string `json:"source,omitempty"`
Held bool `json:"held,omitempty"`
// Take is the operator's pick of this room for the link: the claim moves here unless the holder has a live card.
Take bool `json:"take,omitempty"`
}
PRClaimAsk is what a room says to the hub. Held says this room already has a live row for the key, so the hub records it as the owner and does not place the key elsewhere.
type PRClaimReply ¶
type PRClaimReply struct {
Owner string
Mine bool
Forwarded bool
ForwardStatus int
Forward json.RawMessage
// Live is the owner's live card for the key (its id on the owner's room) when a Take found one.
Live string
// Holder is the owner's live card for the key, on the owner's room, when it is another room's and nothing moved.
Holder string
}
PRClaimReply is the hub's answer. Mine is whether this room owns the key. Forward is the owner's own answer to the paste when the hub handed it over.
type PRFinding ¶
type PRFinding struct {
Key string `json:"key"`
Position int `json:"position"`
File string `json:"file"`
Sev string `json:"sev"`
// Blocking is true when the finding is named and labelled BLOCKING. Its sev is
// `high`. Additive: a client that does not know it loses nothing.
Blocking bool `json:"blocking"`
Path string `json:"path"`
Line int `json:"line"`
Code string `json:"code"`
Link string `json:"link"`
Comment string `json:"comment"`
Evidence map[string]string `json:"evidence"`
Leak string `json:"leak"`
Group string `json:"group"`
Hunk string `json:"hunk"`
Walk PRFindingWalk `json:"walk"`
Text string `json:"text"`
Hash string `json:"hash"`
}
PRFinding is one finding file, parsed.
type PRFindingCounts ¶
type PRFindingCounts struct {
High int `json:"high"`
Med int `json:"med"`
Low int `json:"low"`
Nit int `json:"nit"`
Leak int `json:"leak"`
}
PRFindingCounts is the findings of a run by severity. A leak is also counted under its severity.
type PRFindingWalk ¶
type PRFindingWalk struct {
State string `json:"state"`
At string `json:"at"`
URL string `json:"url"`
}
PRFindingWalk is a finding's line in walk.txt.
type PRRunner ¶
PRRunner runs a review. The daemon's runner replaces the stub that stands here until one is built.
Start hands a queued row to the runner and returns once the row is in the state the runner left it. Abort stops a run that is going. Neither returns an error: a runner that cannot do its job writes `failed` and a reason on the row, which is where the person looks.
type PRWalkCounts ¶
type PRWalkCounts struct {
Accepted int `json:"accepted"`
Done int `json:"done"`
Skipped int `json:"skipped"`
Deferred int `json:"deferred"`
Open int `json:"open"`
}
PRWalkCounts is the findings of a run by walk state.
type Server ¶
type Server struct {
// Room is the name this daemon is known by on a hub, or empty. It only
// words a not-found. See NotOnRoom.
Room string
// Preflight answers what this room process can see and run, by fixed key.
// Human listener only. See internal/daemon/preflight.go for why a body may
// never name a command.
Preflight http.HandlerFunc
// ForgeAccess lists the forge alerts open now, on a room with no hub. See internal/daemon/forgeaccess.go.
ForgeAccess func() any
// Decide resolves a permission. This must go through the daemon rather
// than straight to the store, because the agent is blocked on an in-memory
// reply channel that only the daemon can signal. Writing the decision without
// signalling would leave the runner hanging forever.
Decide func(permID, decision, reason, command string) (*store.Permission, error)
// DecideBy is Decide with the decider named: "" is the operator by hand, and
// the only other value a caller may send is "global-auto", the hub's switch
// (r-020). Owned by the daemon.
DecideBy func(permID, decision, reason, command, by string) (*store.Permission, error)
// Launch starts a runner. The daemon owns process spawning, so the API
// hands the request body straight through rather than reaching for it.
Launch func(body []byte) (*store.Task, error)
// TaskLaunch starts a task of an item: the daemon makes the folder and writes the brief.
TaskLaunch func(body []byte) (*store.Task, error)
// Kill stops the runner behind a card.
Kill func(taskID string) error
// EndThrowaway deletes a throwaway card with its folder, as its runner's exit does.
EndThrowaway func(taskID string)
// Closed is told when a close has moved a card to done, so what it still had held for others is released.
Closed func(t *store.Task)
// CloseHome removes the card's home folder when it holds no file, and answers why it kept one, "" otherwise.
CloseHome func(taskID string) string
// RunAction says a stored action's prompt to a card, and optionally asks
// the runner to leave afterwards. Owned by the daemon, which owns the
// terminals and the message queue.
RunAction http.HandlerFunc
// RunSource runs one intake source now rather than on its interval, and
// reports how many new items it produced. Owned by the daemon, which owns
// process spawning.
//
// The error it returns is the source's, not the request's: a source that
// failed to start is a 200 saying so, because the request worked and the
// answer is the failure.
RunSource func(id string) (int, error)
// Recognise turns a pasted URL into the fields of a launch dialog. Owned by
// the daemon, which owns process spawning: a recogniser's optional fetch is
// an operator-written command, and looking at the directory the templates
// named needs the daemon's filesystem rather than the browser's.
Recognise func(url string) (*rules.Resolved, error)
// PRForge picks the forge for a host, for making a worktree of a pull request. Owned by the daemon.
PRForge func(host string) (forge.Forge, error)
// SCMClone is the scm clone path (atrium_git_clone), for a PR on a repo with no checkout.
SCMClone func(ctx context.Context, url string) (gitsync.SCMResult, error)
// SCMHas is whether the scm folder already holds a clone of the repo at a url. Nil reads as no. It lets a PR
// worktree find the clone while the forge is read. See prWorktree.
SCMHas func(url string) bool
// ScopeHub points a new worktree's remote.hub.url at this room's own forwarder. Nil does nothing. Every path
// that runs `git worktree add` calls it, so the gate never sees a worktree aimed at another room's forwarder.
ScopeHub func(dir string)
// ForgeFailed is told of a forge error so the daemon can raise the board alert, and ForgeWorked of a forge that
// answered so it can clear it. Both are nil-safe seams the daemon fills.
ForgeFailed func(kind string, err error) bool
ForgeWorked func(kind, host string)
// HubSource is a loopback to one repository of the hub's store, for a room with a hub, which reads a PR head
// from there and never from the forge. An error is a room with no hub, or a hub that cannot be reached.
HubSource func(ctx context.Context, name string) (url string, done func(), err error)
// Stash pushes a worktree's work to the hub as stash/<card short id>/<branch>, dirty files in one WIP commit on
// top, and answers the hub branch and repository. A close calls it for a worktree it was told to stash. Nil is
// a room that cannot stash. See close.go.
Stash func(ctx context.Context, card, dir, branch string) (hubBranch, hubRepo string, err error)
// HubDelete deletes a claude/* branch the card pushed from the hub, by a push the hub takes only for a branch that
// card pushed. A close calls it for each hub-branch row. Nil is a room with no hub remote. See closehub.go.
HubDelete func(ctx context.Context, card, dir, hubRepo, branch string) error
// StashRetentionDays is how long the hub keeps a stash before it removes it, for the expiry date a close names. Nil
// is 30, the hub's default. The room does not hear the hub's setting, so a hub set to another number removes it
// on its own date and this one is what the close could say. 0 is never.
StashRetentionDays func() int
// PRFetch fetches a PR head into a ref of the checkout. Nil runs git over https. A seam for tests.
PRFetch func(ctx context.Context, dir string, spec forge.FetchSpec, dst string) error
// PRRunner runs pull request reviews. Nil means the stub that fails every run
// as `runner not built`. See prs.go.
PRRunner PRRunner
// ClaimPR asks the hub to claim a PR key before this room makes a row. Nil is a room with no hub, which makes the
// row with no claim. An error is a hub that could not be asked: the row is made and marked `claim: pending`. See
// prclaim.go.
ClaimPR func(ctx context.Context, ask PRClaimAsk) (PRClaimReply, error)
// Settling reports whether the daemon is still bringing back the sessions
// it had before it restarted. Supplied by the daemon, which is the only
// thing that knows it is mid-boot. Nil in a build without it, which reads
// as "not settling" and is the behavior that existed before.
Settling func() bool
// LoginNeeded is the room's claude login flag for `/v1/health`: nil when fine. LoginHandler is
// `/v1/login-needed`, where DELETE lifts it. See internal/daemon/loginneeded.go.
LoginNeeded func() map[string]any
// DiskWatch is the room's last disk check, for GET /v1/room/disk. See daemon/diskwatch.go.
DiskWatch func() any
// DiskFree reclaims what atrium owns now and answers what it freed.
DiskFree func() any
// HostWatch is the room's last look at its host's processes, for GET /v1/room/host. See daemon/hostwatch.go.
HostWatch func() any
LoginHandler http.HandlerFunc
LoginStatus http.HandlerFunc
// ToolchainMissing is the tools a worker launched here lacked, for `/v1/health`: nil when fine.
ToolchainMissing func() map[string]any
// CancelPending answers every outstanding request on a task with a block.
// Moving a card out of a waiting state has to answer the question rather
// than hide it, or the agent stays frozen with nobody coming.
CancelPending func(taskID, reason string) (int, error)
// Attach upgrades to a WebSocket carrying a supervised runner's terminal.
// Supplied by the daemon, which owns the processes. Registered only when
// set, so a build without supervision has no dead route.
//
// `?kind=shell` asks for the card's shell instead. Absent means the runner,
// which is what every caller written before shells existed sends.
Attach http.HandlerFunc
// OpenShell starts a plain shell in a card's working directory, beside the
// runner's own terminal, and ShutShell ends it.
//
// The one gap in what the board can do that walking to the machine still
// answers: when the agent wedges, the terminal on the card belongs to the
// agent and there is nowhere to type `git status`.
OpenShell http.HandlerFunc
ShutShell http.HandlerFunc
// OlderScrollback serves what this card's terminal held before the last
// restart, ASKED FOR RATHER THAN PUSHED.
//
// It used to be joined onto the front of every attach, and the result was
// two copies of the last hour: a resumed session reprints its own recent
// history, so the carried bytes ended mid-conversation and the same
// conversation began again below the divider. A terminal running claude
// shows one session, and this is how the older one is reached when it is
// wanted.
OlderScrollback http.HandlerFunc
// RawScrollback hands back a card's live ring exactly as it is, with the
// widths and the height in headers.
//
// A DEVELOPMENT SURFACE, and it earns its place: every change to how
// scrollback renders is in Go, so seeing one meant a build and a restart
// and every session interrupted. That loop is slow enough that the
// rendering was twice changed on unit tests alone, and both times the
// tests measured the wrong thing. This is how a renderer gets run over a
// real session offline instead.
RawScrollback http.HandlerFunc
// TextScrollback is the same history as plain text, for reading in a tab
// rather than in a terminal.
TextScrollback http.HandlerFunc
// TypingState is atrium's model of the operator's input line on a card's
// terminal and whether the peer gate is open, for the board's typing
// readout.
TypingState http.HandlerFunc
// LetThrough is the operator's "let it through" on the held messages chip: clear the typed line, deliver what is
// waiting, type the line back. See internal/daemon/letthrough.go.
LetThrough http.HandlerFunc
// TypeAnyway is "type anyway" on the same chip, for a line atrium cannot read: type what is waiting now, past the
// gate, and leave the line alone. See internal/daemon/forcesay.go.
TypeAnyway http.HandlerFunc
// ForceClear is the phone's "Force clear now": discard the text on the card's input line so held messages go in.
// See internal/daemon/forceclear.go.
ForceClear http.HandlerFunc
// DismissAsks takes every outstanding question off a card without telling
// the session anything.
//
// Owned by the daemon rather than answered here, because clearing a
// question writes to the event log and publishes the card, and both of
// those belong with the other three ways an ask gets settled.
DismissAsks http.HandlerFunc
// Message says something to a running session: typed into its terminal
// when atrium owns one, queued for the next hook otherwise.
Message http.HandlerFunc
// Say is a message by address rather than by card id, `name` on this room
// or `name@room` on another, and RoomPeers is who is on the other rooms.
// Owned by the daemon, which owns the relay to the hub. See
// internal/daemon/relay.go.
Say http.HandlerFunc
// Move answers /v1/move/, the steps of a move between rooms. See daemon/moveroutes.go.
Move http.Handler
RoomPeers http.HandlerFunc
// TaskSays lists the says a card sent or received, `GET /v1/tasks/{id}/says`.
TaskSays http.HandlerFunc
// Says lists every say the room recorded, `GET /v1/says`.
Says http.HandlerFunc
// RoomCard and RoomExit read and exit a card on another room by address,
// `name@room` or `room~id`, through the same relay.
RoomCard http.HandlerFunc
RoomExit http.HandlerFunc
// RoomLaunch starts a session on another room, through the hub.
RoomLaunch http.HandlerFunc
// Report is a session on a card reporting to whoever launched it: the
// hub's `atrium_report`. Owned by the daemon, which owns the launcher's
// queue. See internal/daemon/finish.go.
Report http.HandlerFunc
// Stamp reads a card's own directory for the hub's `atrium_record`: the commit, the dirty flag and the branch, and keeps
// the log. Owned by the daemon, which knows where the card is. See internal/daemon/record.go.
Stamp http.HandlerFunc
// RestartWake queues, reads or clears the prompt typed into a card once its
// runner is back after a restart. Owned by the daemon, which owns the
// terminal. See internal/daemon/restartwake.go.
RestartWake http.HandlerFunc
// Need is a lean worker naming what it lacks, which the daemon adds and restarts it with.
Need http.HandlerFunc
// GitClone is `atrium_git_clone`: a clone in the scm folder for a card. Owned by the daemon,
// which holds the settings and asks the one yes. See internal/daemon/gitclone.go.
GitClone http.HandlerFunc
// HubRemote is where this room's hub forwarder is, `http://127.0.0.1:<agent port>/git/`, for the hub's
// atrium_git_url to build a card's URLs on. Empty until the agent listener is bound. Owned by the daemon.
HubRemote func() string
// HubGitURL is the hub's atrium_git_url answer for a card here, `GET /v1/hub/git/url?repo=&branch=&room=`, asked
// of the hub over the link, with the URLs on the link's base for the caller to put on the forwarder. Owned by
// the daemon, which holds the link. See internal/daemon/hubremote.go.
HubGitURL http.HandlerFunc
// HubCI is atrium_ci for a session here, `POST /v1/hub/ci`, asked of the hub over the link, which runs the forge CLI
// and answers the runs, logs and artifacts. Owned by the daemon. See internal/daemon/hubci.go.
HubCI http.HandlerFunc
// HubAsk is atrium_backlog and atrium_reports for a session here, `POST /v1/hub/ask`, asked of the hub over the
// link. Owned by the daemon. See internal/daemon/hubask.go.
HubAsk http.HandlerFunc
// RoomCaps and RoomCapsRun are `GET /v1/capabilities` and `POST /v1/capabilities/run`. Owned by the daemon.
RoomCaps, RoomCapsRun http.HandlerFunc
// HubCall is one ask of the hub over the link, answered as a status, the hub's data and a refusal's sentence. It is
// what a card's subscriptions ride. Owned by the daemon. See internal/daemon/hubask.go.
HubCall func(ctx context.Context, from, method, path string, body json.RawMessage) (int, json.RawMessage, string)
// ItemAct is `POST /v1/items/{id}/{unblock|cancel}`, which the hub calls for an item's owner. Owned by the daemon.
// See internal/daemon/item_hub.go.
ItemAct http.HandlerFunc
// PoolSubmit is `POST /v1/pools/{pool}/items`, which the hub calls to queue an item on a pool. Owned by the daemon.
PoolSubmit http.HandlerFunc
// Hold reads, sets or lifts the room deploy hold. Owned by the daemon, which
// runs the permission chain it acts in. See internal/daemon/roomhold.go.
Hold http.HandlerFunc
// NewContext starts a card's capture, clear and wake sequence, reads it or
// takes its chip off. Owned by the daemon, which owns the terminal. See
// internal/daemon/newcontext.go.
NewContext http.HandlerFunc
// Resume wakes a parked card. Supplied by the daemon. See daemon/park.go.
Resume http.HandlerFunc
// MoveIn ends a session joined from outside atrium and resumes it under atrium. See daemon/movein.go.
MoveIn http.HandlerFunc
// SendNote turns a card's note into one message and clears it. Owned by
// the daemon, which owns delivery.
SendNote http.HandlerFunc
// SwitchModel types `/model <id>` into a live claude card and records the
// choice, `POST /v1/tasks/{id}/model`. Owned by the daemon, which owns the
// terminal. See daemon/modelswitch.go.
SwitchModel http.HandlerFunc
// CloneSource answers what the board's clone form is filled from, `GET /v1/tasks/{id}/clone`. See daemon/clone.go.
CloneSource http.HandlerFunc
// DrainAuto approves everything already waiting, when auto mode is turned
// on with a full queue. Supplied by the daemon for the same reason Decide
// is: each waiting agent is parked on an in-memory reply channel, and a
// decision written straight to the store never reaches it.
DrainAuto func() (int, error)
// Shutdown winds the daemon down. Supplied by the daemon, which is the only
// thing that can stop itself and owns the access rules for doing so.
Shutdown http.HandlerFunc
// HostState answers `GET /v1/preflight` with whether the pty host is on, whether it would die with the room's
// task, and its build. Supplied by the daemon.
HostState http.HandlerFunc
// RestartWrap asks the working sessions to wrap up before a restart, and answers when they have or the wait
// is out. Supplied by the daemon, with Shutdown's access rules.
RestartWrap http.HandlerFunc
// RestartPtyHost restarts the room's pty host and reopens its cards, with the room staying up. Supplied by the
// daemon, with Shutdown's access rules.
RestartPtyHost http.HandlerFunc
// Shelve stops the runner behind a card being put down. The card and its
// resume id stay, so the work is paused rather than ended.
Shelve func(taskID string) error
// StopRunner asks a runner to exit the way its harness says to, rather
// than killing it. Supplied by the daemon, which owns the terminal.
StopRunner func(taskID string) error
// StopRunnerBy is StopRunner naming who asked, so the exit is recorded as asked for. Preferred when set.
StopRunnerBy func(taskID, by string) error
// Cull asks a merged worker to leave and removes its worktree and branch.
// Supplied by the daemon, which owns the terminal and makes every check.
// See internal/daemon/cull.go.
//
// `tip` is a merge proof made on another machine: the commit the area branch
// was checked to contain, which this room's worktree has to be sitting on.
// Empty when the proof is made here.
Cull func(taskID, into, tip string) (any, error)
// Homes is the Disk view and HomeRemove its remove button, which takes a ledger row id and never a path. See
// internal/daemon/homedisk.go.
Homes func() (any, error)
HomeRemove func(id string) (any, error)
HomeOpen func(id string) (any, error)
// GitPush is atrium_git_push: the room pushes one plain branch from the card's own directory to the hub through
// its hub forwarder, under the same rules as `git push hub <branch>`. See internal/daemon/hubremote.go.
GitPush func(taskID, branch string) (any, error)
// HoldCull keeps a worker: the merged-cull mark is dropped and nothing marks
// it again. A route of its own, and not a flag on cull, because a room that
// predates the hold would read `hold=true` as an ordinary cull and cull it.
HoldCull func(taskID, by string) error
// WorktreesAudit is POST /v1/worktrees/audit, atrium_worktrees: one line per worktree of a repository. Nil leaves the
// route off. See internal/daemon/worktrees.go.
WorktreesAudit func(w http.ResponseWriter, r *http.Request)
// Merged is the post-merge hook's request: mark the finished workers a merge
// into `into` covered, limited to `branches` when given. Human listener only,
// never the guest allowlist.
Merged func(into string, branches []string) (any, error)
// ArchiveWorkers is the one-time tidy of done worker cards. Human listener
// only. `dryRun` changes nothing and lists what would go.
ArchiveWorkers func(dryRun bool) (any, error)
// MergeProof is the proof half of a cross-room cull: is `ref` (a fetched
// `<room>/claude/<id>`) contained in `into`, in the repository of `dir`.
// Answers `{into, ref, tip, merged}`. Human listener only.
MergeProof func(dir, ref, into string) (any, error)
// RestartRunner asks a runner to exit, waits for it to be gone, and starts
// the same conversation again on the SAME card. Unshelve without the shelve,
// for a wedged session or one running an old binary. Supplied by the daemon,
// which owns the terminal and process spawning.
RestartRunner func(taskID string) (*store.Task, error)
// Unshelve starts it again from where the conversation left off. Returns
// whether it started, and why not when it did not, so the board can say so.
Unshelve func(taskID string) (bool, string, error)
// SetKeepalive flips a card's cache keep-alive switch and returns what the
// board draws for it. Owned by the daemon. See internal/daemon/keepalive.go.
SetKeepalive func(taskID string, on bool) (any, error)
// UsageOf is a card's token use on record, for its details. Owned by the
// daemon. See internal/daemon/usage.go.
UsageOf func(taskID string, limit int) (any, error)
// Replies is a card's last n replies as text, for the phone's conversation
// page (r-024), or the n older than before when it is not zero. Owned by the
// daemon, which reads the transcript. See internal/daemon/replies.go.
Replies func(taskID string, n int, before time.Time) (any, error)
// RepliesAll answers `replies?all=1`: every reply the card's transcripts still hold, bounded, for the copy
// clean button. See internal/daemon/repliesall.go.
RepliesAll func(taskID string) (any, error)
// Changes is what a card's worktree has changed, or what one turn's edit calls
// changed when turn is not zero. Owned by the daemon, which runs git. A refusal
// is a *ChangesError. See internal/daemon/changes.go.
Changes func(ctx context.Context, taskID, against string, turn time.Time) (any, error)
// RoomStats is the last `room-stats` snapshot the sampler pushed, as JSON,
// or nil before the first. Does no work of its own. Owned by the daemon.
// See internal/roomstats.
RoomStats func() []byte
// KillOrphan is the room alert's kill: a process under a closed card's home, read again first. Owned by
// the daemon. See internal/daemon/roomalert.go.
KillOrphan func(pid int) error
// Overlays reports how the board can be reached from elsewhere, and turns
// those ways on and off. Supplied by the daemon, which owns the child
// process a share runs as.
Overlays func() any
// SaveOverlay stores one overlay's configuration.
SaveOverlay func(kind string, body []byte) error
// StartOverlay opens a share, StopOverlay closes it.
StartOverlay func(kind string) error
StopOverlay func(kind string) error
// SetupOverlay does the one thing standing between this machine and being
// able to share at all: a zrok environment, or a ziti identity. Returns
// what the tool said, on failure as well as success.
SetupOverlay func(kind string, body []byte) (string, error)
// AccessZitiDir is where an OpenZiti entry's identity is kept, one file per entry.
AccessZitiDir func() string
// TeardownOverlay undoes that.
TeardownOverlay func(kind string) (string, error)
// InspectToken reads an enrollment token without acting on it, so the
// board can show what it is for before anything is done with it.
InspectToken func(token string) (any, error)
// ReserveName holds a zrok name so the board's address survives a restart.
// Returns the name selection to configure the share with.
ReserveName func(namespace, name string) (string, error)
// Capabilities asks a ziti network what this identity may bind, so
// "is this going to work" is answerable without pressing start.
Capabilities func() any
// ZrokAccount reports what the zrok account behind this machine is already
// using, so an account at a limit is visible before a button is pressed
// rather than several seconds after. `internal/daemon/overlay_limits.go`
// has what zrok will and will not tell an account token.
ZrokAccount func() any
// SetApiEndpoint points this machine at a zrok instance other than the
// public one. Empty puts it back on zrok's default.
SetApiEndpoint func(own bool, endpoint string) error
// Lending ONE session to one person, which is a different thing from
// publishing the board and is deliberately not built on it: the board
// share hands over every card, and this hands over a single terminal.
// One document from a card on its own public share. See `internal/daemon/docshare.go`.
// BuildExport hands back this atrium's configuration as something a
// repository can hold, or REFUSES and says why. Refusing is the interesting
// case: it means something in the configuration looks like a credential,
// and a secret pushed to a repository is still in its history after it is
// deleted. See `internal/daemon/export.go`.
// AuthConfig reports the login in front of the PUBLISHED board, WITHOUT
// its client secret, and SaveAuth stores one. See `internal/daemon/auth.go`
// for what this does and does not apply to.
AuthConfig func() any
SaveAuth func(body []byte) error
// Rooms is the other machines reporting into this hub, and RoomCheckIn is
// how one does it. Held by the daemon, in memory, because a room's cards
// belong to that room's database and a durable copy here would be a second
// source of truth. See `internal/daemon/rooms.go`.
Rooms func() any
RoomCheckIn func(w http.ResponseWriter, r *http.Request)
// RoomDecide answers a permission request raised on one of those machines.
// It queues the decision for the room to collect, and nothing more: the
// blocked channel is in that room's process, so the room unblocks its own
// request. This is not `Decide`, which resolves a request in this store.
RoomDecide func(w http.ResponseWriter, r *http.Request)
// RoomJoin is what to run on another machine to make it a room. Read only,
// and pressing nothing here creates anything: a room exists exactly when
// it checks in. RoomForget drops one early, which is the same thing time
// does and is equally not durable.
RoomJoin func() any
HubLink func() any
// SSHWizard runs the read only checks for turning ssh on, `GET /v1/ssh/wizard`. A check only reads, so the
// route is served on every board including through the hub. Nothing on this surface writes. 404 on a daemon.
SSHWizard func(r *http.Request) any
RoomForget func(w http.ResponseWriter, r *http.Request)
// The other direction: work queued for another machine, which rides the
// reply to the check-in that room was already making. Unlike the room list
// this IS durable, because it is this machine's own record of something it
// asked for rather than a copy of somebody else's card.
// `DispatchResult` is the room reporting back and carries its own token, so
// it is not gated on anything this layer knows.
Dispatches func() any
QueueDispatch func(body []byte) (any, error)
CancelDispatch func(id string) error
DispatchResult func(w http.ResponseWriter, r *http.Request)
// BoardDir serves board files from disk for development, allowing changes
// without restarting the daemon. Empty uses the embedded copy.
BoardDir string
// StateDir is the room's state folder, where the operator's board/user.css lives. Empty serves an empty one.
StateDir string
BuildExport func() (any, error)
// ApplyImport reads one back. `apply` false answers what it WOULD do, which
// is the question somebody restoring a machine actually has, and is the
// default for that reason.
ApplyImport func(body []byte, apply, force bool) (any, error)
// CloneFromHub clones a repository from the hub's copy into the scm folder, for the launch dialog's repo list. Nil
// or an error is a room with no hub to clone from, and it never reads a forge. See checkouts.go.
CloneFromHub func(ctx context.Context, url string) (gitsync.SCMResult, error)
// BranchCheck says whether a launch's branch exists or is held by another worktree. See home.BranchCheck.
BranchCheck func(repo, branch string) (any, error)
// contains filtered or unexported fields
}
Server serves the human-facing API.
func (*Server) CardColors ¶
func (s *Server) CardColors() CardColors
CardColors reads the setting, seeding it when the row does not exist.
func (*Server) Close ¶
func (s *Server) Close()
Close releases every SSE subscriber. An event stream is an open request, and http.Server.Shutdown waits for those, so without this a single browser tab holds the board listener open until the shutdown grace period expires.
func (*Server) ContainedOrOpen ¶
ContainedOrOpen is containedOrOpen against this server's open roots, for the room to bound a path a card names.
func (*Server) PreviewPort ¶ added in v0.0.4
PreviewPort is whether the hub may forward a browser to 127.0.0.1:port on this room: the room's card range or the previews' block, so atrium's own listeners, which trust loopback, are never one.
func (*Server) PublishPR ¶
PublishPR sends a row's current state on the event stream. The runner calls it as steps finish.
func (*Server) PublishTask ¶
PublishTask broadcasts a "task" event carrying the same row a /v1/tasks list holds for the card, so the board can upsert it without a re-fetch. Every "task" broadcast goes through here.
It does not run the queries: it marks the card pending and returns. A mark already standing for the card (taskCoalesce) absorbs the call, and the send reads the card then, so the event always carries the latest state and a burst costs one card's worth of queries per window. See flushTask.
func (*Server) ReconcilePRClaims ¶
func (s *Server) ReconcilePRClaims()
ReconcilePRClaims asks the hub about every row made while it could not be reached. It runs when the room attaches again, and nothing else calls it: no timer. A key another room claimed first folds this row into that room's: a row that has not started is aborted, and one that has is left to finish and labelled, because deleting a finished review is worse than showing two.
func (*Server) SkinOrDefault ¶
SkinOrDefault reads the stored skin, answering the default for both an unset setting and a stored name that is no longer shipped.
The second case is the one worth handling: a skin removed from a later build would otherwise leave the board on a name nothing matches, which looks like the setting being ignored rather than the skin being gone.
type TurnFinding ¶
type TurnFinding struct {
Kind string `json:"kind"`
Turns int `json:"turns"`
Tokens int64 `json:"tokens"`
LimitTurns int `json:"limit_turns"`
LimitTokens int64 `json:"limit_tokens"`
// Over is which limit was passed: turns, tokens or both.
Over string `json:"over"`
// Item is the backlog item that would remove this cause, "" when none is known.
Item string `json:"item,omitempty"`
}
TurnFinding is one cause kind over a limit today.
func CheckTurnLimits ¶
func CheckTurnLimits(rows []store.CostRow, day string, lim store.TurnLimits) []TurnFinding
CheckTurnLimits is the findings for one day's rows. The operator's own turns are not a cause to flag. Tokens are counted as the usage tab counts them, cache reads apart. Findings come out most turns first.
type TurnLimitReport ¶
type TurnLimitReport struct {
// Day is the UTC day counted.
Day string `json:"day"`
Off bool `json:"off"`
Findings []TurnFinding `json:"findings"`
}
TurnLimitReport is the answer of GET /v1/usage/turn-limits.
type UsageWeekReset ¶
type UsageWeekReset struct {
Day string `json:"day"` // sun, mon, tue, wed, thu, fri or sat
Time string `json:"time"` // 24 hour HH:MM
TZ string `json:"tz"` // an IANA zone name
}
UsageWeekReset is when the weekly usage limit resets: a fixed weekday and wall time in a named zone, not a rolling seven days. The usage tab's "this week" range starts at the last one. One per board, kept as a setting, so every browser on the board agrees. The reset itself is worked out in the browser (js/usage-charts.js), which is where the tab is drawn.
func (UsageWeekReset) Check ¶
func (u UsageWeekReset) Check() error
Check says why a reset is not usable, or nil.
Source Files
¶
- access_ziti.go
- actions.go
- api.go
- artifacts.go
- auth.go
- browse.go
- browseroots.go
- cardcolors.go
- cardnames.go
- cardoverlay.go
- cardports.go
- cardprocstart.go
- cardsarchive.go
- changes.go
- checkoutcase.go
- checkouts.go
- close.go
- closeadopt.go
- closeclone.go
- closehub.go
- closeprogress.go
- contextsize.go
- deliveryexport.go
- discover.go
- docshare.go
- exitguard.go
- export.go
- filedrop.go
- filelist.go
- fileopen.go
- fileprobe.go
- files.go
- filetext.go
- fileview.go
- filezip.go
- fixtures.go
- homes.go
- hooks.go
- icon.go
- inputlag.go
- intake.go
- keepalive.go
- launchcwd.go
- limits.go
- logline.go
- longpath_other.go
- newwork.go
- open.go
- openkinds.go
- openpaths.go
- openprogress.go
- overlays.go
- page.go
- parent.go
- placement.go
- prbrief.go
- prclaim.go
- providerapi.go
- providers.go
- prpanel.go
- prs.go
- prsdrawer.go
- prsfolder.go
- prsmove.go
- prworktree.go
- recognisers.go
- replies.go
- resources.go
- review.go
- runnersetup.go
- scratch.go
- scrollback.go
- serverhooks.go
- sessionexport.go
- sessions.go
- settings.go
- setupcheck.go
- shell_other.go
- skins.go
- state.go
- subscriptions.go
- sweep.go
- tangent.go
- termopen.go
- termthemes.go
- termwidth.go
- throwaway.go
- touched.go
- turncost.go
- turnlimits.go
- twig.go
- usage.go
- usageexport.go
- usageitems.go
- usageweek.go
- usercss.go
- walkagent.go
- walkdiff.go
- walkstate.go
- web.go
- worktreeleft.go