Documentation
¶
Overview ¶
Package agentstatus keeps an agent's STORED status following its instance: it promotes a row stored as `provisioning` to `running` once the instance behind it is live and ready.
🔴 WHY IT EXISTS: NOTHING ELSE EVER WROTE `running` FOR A FRESH AGENT. Every write path stores `provisioning` and stops there:
- agentprovision.Adapter.Dispatch creates the instance and stores `provisioning`;
- agentprovision.Adapter.Start stores `provisioning` for an agent that was never kicked off (a saved agent, a claude-code agent, a restart before the first turn) and returns;
- internal/agentkickoff delivers the first turn and stamps kicked_off, but never writes a status — it deliberately leaves agents.ActionPersistStatus untaken (its Tick says so);
- and agents.DecideReconcile's ActionPersistStatus, the table entry that would have done it, had no driver at all (reconcile.go's footer named it).
The HTML views never showed it, because they refine the stored status against the live instance on every render (agents.ComputeStatus via internal/api's liveStatus). Every reader of the STORED column did: GET /api/agents and `muster agent ls` reported `provisioning` for agents that had been Ready for hours, the claude-code account pool counted them as live, and the "agent ready" push (api.Server.notifyAgentRunning, which re-reads the stored status) never fired for a task-linked agent.
🔴 IT PROMOTES AND NOTHING ELSE. The one transition is the one the stored status was missing, decided by agents.PromoteToRunning. Demotions (running → provisioning/error/stopped) are NOT taken here: the stuck and lost-kickoff verdicts belong to agentkickoff and the decision table, and Stop writes `stopped` itself.
🔴 IT IS CONDITIONAL ON THE ROW NOT HAVING MOVED (agents.Store.MarkRunning compares status AND updated_at). The verdict comes from a row list and a separate instance list; a Stop, a Start or an error written in between must win.
⚠ ITS OWN LOOP, NOT A PHASE OF agentkickoff, ON PURPOSE: the deliverer only exists when a gateway is configured (cmd/muster-server's buildKickoffDeliverer), and an agent's status is true or false regardless of whether anything can deliver it a first turn.
Index ¶
Constants ¶
const DefaultInterval = 10 * time.Second
DefaultInterval is how often Promoter.Run looks. A pod takes tens of seconds to become ready; this bounds how long after that the stored status lags.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Store is the agents store. REQUIRED.
Store agents.Store
// Instances lists live instances. REQUIRED.
Instances InstanceLister
// NamespacePrefix is the deployment's configured agent namespace prefix; a
// row is this deployment's iff its namespace is agents.NamespaceFor(prefix,
// name). Rows another system wrote are never touched.
NamespacePrefix string
// Logger is optional.
Logger *log.Logger
// OnChange, when set, is called with an agent's name after its status is
// promoted. cmd/muster-server passes api.Server.BroadcastAgentChanged, which
// re-renders open Agents lists and Tasks boards and fires the "agent ready"
// push for a task-linked agent.
OnChange func(name string)
}
Config is everything the promoter needs.
type InstanceLister ¶
InstanceLister lists live instances. agentprovision.Adapter satisfies it.
type Promoter ¶
type Promoter struct {
// contains filtered or unexported fields
}
Promoter promotes provisioning rows whose instance is ready. Build it with New.
func (*Promoter) Done ¶
func (p *Promoter) Done() <-chan struct{}
Done is closed once Promoter.Run has returned.
func (*Promoter) Run ¶
Run ticks every interval until ctx is cancelled, then closes Promoter.Done.