Documentation
¶
Overview ¶
Package assign executes the coordinator's ModelAssignment pushes on the operator's terms (SPEC §4.1, §4.4; plan 05).
The mesh may fill this node with models — download, load, and later evict what it placed — but only inside the operator's consent:
- the models mesh_managed switch (default on; off = decline all),
- max_disk_mb (a placement that cannot fit even after evicting other mesh-placed models is declined, never forced),
- pin (never evicted) and exclude (never assigned),
- and the operator's own models, which the mesh cannot evict at all (cache entries carry an origin; only "mesh" ones are the mesh's).
Every decision is reported back over the tunnel as a ModelState: "assigned" (accepted, queued), "downloading", "ready", "declined" (policy), "failed" (error), "evicted". The coordinator uses declined / failed to back off, and the heartbeat carries assigned/downloading so placement knows a replica is on its way.
Index ¶
- Constants
- type Pending
- type Policy
- type Service
- func (s *Service) Apply(ctx context.Context, ma *tunnelv1.ModelAssignment)
- func (s *Service) Get(id string) (Pending, bool)
- func (s *Service) Pending() []Pending
- func (s *Service) Run(ctx context.Context)
- func (s *Service) SetReporter(fn func(*typesv1.ModelState) error)
- func (s *Service) States() []*typesv1.ModelState
Constants ¶
const ( StateAssigned = "assigned" StateDownloading = "downloading" StateReady = "ready" StateDeclined = "declined" StateFailed = "failed" StateEvicted = "evicted" )
States reported to the coordinator and shown in the local API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pending ¶
type Pending struct {
ID string `json:"id"`
State string `json:"state"`
Since time.Time `json:"since"`
// Error is the failure or refusal reason (failed/declined only).
Error string `json:"error,omitempty"`
}
Pending is one assignment the node is working on or has concluded.
type Policy ¶
Policy is the operator's standing consent, read fresh per decision so a dashboard toggle applies to the next assignment without a restart.
type Service ¶
type Service struct {
Ops *modelops.Service
Mgr *models.Manager
Eng *engine.Engine
// OnBattery reports power state; downloads wait while true.
OnBattery func() bool
// Policy returns the current consent. Required.
Policy func() Policy
// Events receives model_assignment events. May be nil.
Events *events.Hub
Log *slog.Logger
// contains filtered or unexported fields
}
Service applies assignments. Nil Ops (mock runtime) declines everything with a clear reason so the coordinator backs off instead of retrying.
func (*Service) Apply ¶
func (s *Service) Apply(ctx context.Context, ma *tunnelv1.ModelAssignment)
Apply handles one ModelAssignment: evictions first (they free the disk the assignments need), then admission of each assignment under the policy. Idempotent: a repeated push for a model already ready or in flight is acknowledged, not restarted.
func (*Service) SetReporter ¶
func (s *Service) SetReporter(fn func(*typesv1.ModelState) error)
SetReporter installs the tunnel send used for ModelStateUpdate messages (swapped on every (re)connect). Reports while disconnected are dropped; the next Hello/heartbeat carries the live states anyway.
func (*Service) States ¶
func (s *Service) States() []*typesv1.ModelState
States returns the in-flight assignments for Hello/heartbeat model lists (assigned + downloading only; failures/refusals are one-shot reports, otherwise the coordinator would read every heartbeat as a fresh one).