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
- func LoadRawExecutionPolicy(path, projectsRoot string) (bool, error)
- func RawExecutionPolicyPath() (string, error)
- func RequireRawExecutionPolicy(path, projectsRoot string) error
- type Provenance
- type Queue
- type Service
- func (service *Service) CancelOperation(_ context.Context, request *connect.Request[daemonv1.CancelOperationRequest]) (*connect.Response[daemonv1.Operation], error)
- func (service *Service) CompleteOperation(_ context.Context, request *connect.Request[daemonv1.CompleteOperationRequest]) (*connect.Response[daemonv1.CompleteOperationResponse], error)
- func (service *Service) DisconnectWorker(_ context.Context, request *connect.Request[daemonv1.DisconnectWorkerRequest]) (*connect.Response[daemonv1.DisconnectWorkerResponse], error)
- func (service *Service) GetDaemonInfo(_ context.Context, _ *connect.Request[daemonv1.GetDaemonInfoRequest]) (*connect.Response[daemonv1.GetDaemonInfoResponse], error)
- func (service *Service) GetOperation(_ context.Context, request *connect.Request[daemonv1.GetOperationRequest]) (*connect.Response[daemonv1.Operation], error)
- func (service *Service) HeartbeatOperation(_ context.Context, ...) (*connect.Response[daemonv1.HeartbeatOperationResponse], error)
- func (service *Service) LeaseOperation(ctx context.Context, request *connect.Request[daemonv1.LeaseOperationRequest]) (*connect.Response[daemonv1.LeaseOperationResponse], error)
- func (service *Service) RegisterWorker(_ context.Context, request *connect.Request[daemonv1.RegisterWorkerRequest]) (*connect.Response[daemonv1.RegisterWorkerResponse], error)
- func (service *Service) StartLeaseRecovery(ctx context.Context)
- func (service *Service) SubmitOperation(_ context.Context, request *connect.Request[daemonv1.SubmitOperationRequest]) (*connect.Response[daemonv1.Operation], error)
- func (service *Service) WaitOperation(ctx context.Context, request *connect.Request[daemonv1.WaitOperationRequest]) (*connect.Response[daemonv1.Operation], error)
- type State
- type Status
- type Store
Constants ¶
const ( StateSchemaVersion = 1 QueueSchemaVersion = 1 )
const ( ProtocolVersion = 1 QueueSchema = 1 )
const RawExecutionPolicyVersion = 1
Variables ¶
This section is empty.
Functions ¶
func LoadRawExecutionPolicy ¶ added in v0.105.0
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 RequireRawExecutionPolicy ¶ added in v0.105.0
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 (*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
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
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.