agentstatus

package
v0.121.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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-fetches open agent pages' strips, sidebars 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

type InstanceLister interface {
	Instances(ctx context.Context) ([]provision.Instance, error)
}

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 New

func New(cfg Config) (*Promoter, error)

New validates cfg and builds the promoter.

func (*Promoter) Done

func (p *Promoter) Done() <-chan struct{}

Done is closed once Promoter.Run has returned.

func (*Promoter) Run

func (p *Promoter) Run(ctx context.Context, interval time.Duration)

Run ticks every interval until ctx is cancelled, then closes Promoter.Done.

func (*Promoter) Tick

func (p *Promoter) Tick(ctx context.Context) (int, error)

Tick makes one pass and reports how many rows it promoted.

🔴 A FAILED INSTANCE LIST ENDS THE TICK WITH NO ACTION. An unobserved backend is not evidence of anything; the next tick looks again.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL