daemon

package
v0.125.7 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package daemon owns the durable local lifecycle record for the WB daemon.

The record deliberately contains scheduler ownership, rather than command output, so a later ConnectRPC/gRPC transport and the MCP adapter can use the same queue handoff contract without reading a dashboard-only file.

Package daemon owns WB's durable local operation queue.

Index

Constants

View Source
const (
	StateSchemaVersion = 1
	QueueSchemaVersion = 1
)
View Source
const (
	ProtocolVersion = 1
	QueueSchema     = 1
)
View Source
const RawExecutionPolicyVersion = 1

Variables

This section is empty.

Functions

func LoadRawExecutionPolicy added in v0.105.0

func LoadRawExecutionPolicy(path, projectsRoot string) (bool, error)

LoadRawExecutionPolicy enables raw subprocesses only through a protected, explicit administrator opt-in outside the agent-writable projects tree.

func RawExecutionPolicyPath added in v0.105.0

func RawExecutionPolicyPath() (string, error)

func RequireRawExecutionPolicy added in v0.105.0

func RequireRawExecutionPolicy(path, projectsRoot string) error

RequireRawExecutionPolicy re-reads and validates the protected host policy. Callers must invoke it at every execution boundary so revocation is immediate.

Types

type Provenance

type Provenance struct {
	Executable string `json:"executable"`
	SHA256     string `json:"sha256"`
	Version    string `json:"version"`
	Revision   string `json:"revision,omitempty"`
	Built      string `json:"built,omitempty"`
}

Provenance identifies the exact executable trusted to own a daemon generation. SHA256 is intentionally included even when the released version is known: a development binary can otherwise look identical to a release.

func ProvenanceForExecutable

func ProvenanceForExecutable(executable, version, revision, built string) (Provenance, error)

ProvenanceForExecutable produces exact local evidence for a running binary.

func (Provenance) SameBinary

func (p Provenance) SameBinary(other Provenance) bool

type Queue

type Queue struct {
	SchemaVersion int         `json:"schema_version"`
	Generation    uint64      `json:"generation"`
	Owner         Provenance  `json:"owner"`
	OwnerToken    string      `json:"owner_token"`
	HandoffFrom   *Provenance `json:"handoff_from,omitempty"`
	HandoffAt     *time.Time  `json:"handoff_at,omitempty"`
}

Queue describes durable queue ownership. Operations are added by the async scheduler lane; lifecycle code preserves this object byte-for-byte apart from a fenced owner/generation transition.

type Service added in v0.105.0

type Service struct {
	// contains filtered or unexported fields
}

Service implements the generated ConnectRPC service and persists every state transition before it is returned to the caller.

func NewService added in v0.105.0

func NewService(projectsRoot, build, generation string, authorizeRaw func() error) (*Service, error)

func (*Service) CancelOperation added in v0.105.0

func (*Service) CompleteOperation added in v0.106.0

func (*Service) DisconnectWorker added in v0.106.0

func (*Service) GetDaemonInfo added in v0.105.0

func (*Service) GetOperation added in v0.105.0

func (*Service) HeartbeatOperation added in v0.106.0

func (*Service) LeaseOperation added in v0.106.0

func (*Service) RegisterWorker added in v0.106.0

func (*Service) StartLeaseRecovery added in v0.106.0

func (service *Service) StartLeaseRecovery(ctx context.Context)

StartLeaseRecovery watches running worker leases even when no client is polling an operation. The daemon owns only this recovery clock; execution remains in the connected worker process.

func (*Service) SubmitOperation added in v0.105.0

func (*Service) WaitOperation added in v0.105.0

type State

type State struct {
	SchemaVersion int        `json:"schema_version"`
	Status        Status     `json:"status"`
	PID           int        `json:"pid,omitempty"`
	OwnerToken    string     `json:"owner_token,omitempty"`
	Listen        string     `json:"listen"`
	Provenance    Provenance `json:"provenance"`
	Queue         Queue      `json:"queue"`
	StartedAt     time.Time  `json:"started_at,omitempty"`
	UpdatedAt     time.Time  `json:"updated_at"`
}

State is private local state. It is never served by the dashboard API.

func NewStarting

func NewStarting(previous *State, listen string, provenance Provenance, ownerToken string, now time.Time) State

NewStarting creates the next fenced queue generation. Existing queue jobs stay in the durable queue file owned by the scheduler; this record tells the replacement scheduler exactly which binary owned the preceding generation.

func (*State) MarkDraining

func (s *State) MarkDraining(now time.Time)

func (*State) MarkReady

func (s *State) MarkReady(pid int, now time.Time)

func (*State) MarkStopped

func (s *State) MarkStopped(now time.Time)

func (State) Valid

func (s State) Valid() error

type Status

type Status string
const (
	StatusStarting Status = "starting"
	StatusReady    Status = "ready"
	StatusDraining Status = "draining"
	StatusStopped  Status = "stopped"
)

type Store

type Store struct{ Path string }

Store reads and atomically replaces the local state record. Its directory and file permissions keep operation/queue metadata per-user on Unix; the Windows service adapter will use the current-user application-data ACL.

func (Store) Load

func (s Store) Load() (State, bool, error)

func (Store) Save

func (s Store) Save(state State) error

Jump to

Keyboard shortcuts

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