fleetwork

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Overview

Package fleetwork is the use-case layer for the fleet work order lifecycle (#407, epic #405): issue a signed, addressed, authorised order; let an agent claim orders addressed to it; and drive orders through the validated state machine. It audits every mutation and keeps the domain pure. The store enforces tenant isolation (RLS), idempotency and the in-flight uniqueness guard; this layer signs, validates transitions, and audits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IssueInput

type IssueInput = ports.FleetWorkIssueInput

IssueInput remains an alias for compatibility; the issuance DTO lives in ports.

type Service

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

Service is the work order use case.

func NewService

NewService validates its dependencies and returns the service.

func (*Service) Claim

func (s *Service) Claim(ctx context.Context, actor string, tenantID, agentID shared.ID, max int) ([]*workorder.WorkOrder, error)

Claim atomically claims up to max unexpired orders addressed to agentID, moving them from issued to claimed, and audits each claim.

func (*Service) CompleteResponse added in v0.2.0

func (s *Service) CompleteResponse(ctx context.Context, actor string, tenantID, id shared.ID, result fleetagent.ResponseExecutionResult, reason string) error

CompleteResponse persists a lease-bound endpoint execution result and its terminal work-order state atomically. The result records application only; independent telemetry still verifies effect.

func (*Service) FenceResponses added in v0.2.0

func (s *Service) FenceResponses(ctx context.Context, actor string, tenantID shared.ID, generation int64, reason string) error

FenceResponses cancels every live effect command below a durable tenant halt generation.

func (*Service) GetByID

func (s *Service) GetByID(ctx context.Context, tenantID, id shared.ID) (*workorder.WorkOrder, error)

GetByID returns the order or shared.ErrNotFound.

func (*Service) GetByIdempotencyKey added in v0.2.0

func (s *Service) GetByIdempotencyKey(ctx context.Context, tenantID shared.ID, idempotencyKey string) (*workorder.WorkOrder, error)

func (*Service) Issue

func (s *Service) Issue(ctx context.Context, actor string, in IssueInput) (*workorder.WorkOrder, error)

Issue builds, signs and persists a work order. It is idempotent by (tenant, idempotency key): re-issuing returns the existing order. A second live order for the same (tenant, asset, capability, time bucket) is rejected by the store with shared.ErrConflict.

func (*Service) SetExecutionAuthorizer added in v0.2.0

func (s *Service) SetExecutionAuthorizer(guard ports.ExecutionAuthorizer)

SetExecutionAuthorizer installs the current-state guard used at the endpoint execution boundary.

func (*Service) Transition

func (s *Service) Transition(ctx context.Context, actor string, tenantID, id shared.ID, leaseID string, to workorder.State, reason string) error

Transition moves an order to a new state after validating the transition is legal for its current state, using an optimistic expected-state check in the store. reason is required for a refusal.

func (*Service) Verify

func (s *Service) Verify(wo *workorder.WorkOrder) bool

Verify reports whether the order's signature matches its current authorising fields. The agent runtime (a later issue) uses this before acting; exposed here so the signing contract is testable.

Jump to

Keyboard shortcuts

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