Documentation
¶
Overview ¶
Package mission — Command payload + processor component.
A MissionCommand is a Graphable that stamps a `mission.command` triple on the mission entity's ENTITY_STATES record. The rule engine watches ENTITY_STATES; when `mission.command=launch` appears on a mission entity, the lifecycle-mission-launch rule fires lifecycle_transition to drive the Manager state.
The processor is intentionally tiny — pure NATS Subscribe (not JetStream consumer), no batching, no retry — because its only job in the e2e tier is to translate UDP → Graphable. Production apps wanting a similar shape would use the iot_sensor example as a template for richer transport handling.
Package mission implements the demo Mission lifecycle workflow used by the lifecycle e2e tier. State is the Participant; Transitions declares the phase graph; Register wires the workflow into pkg/lifecycle.Manager.
The package intentionally lives under cmd/e2e-semstreams so the production semstreams binary does not register this workflow — per ADR-049 the framework provides the substrate (Manager, lifecycle-gateway component, lifecycle_* rule actions); apps own their workflow types.
Index ¶
- Constants
- Variables
- func EntityIDFor(orgID, platform, missionID string) string
- func NewComponent(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
- func Register(registry *component.Registry) error
- func RegisterPayloads(reg *payloadregistry.Registry) error
- func WorkflowDeclaration() lifecycle.Workflow
- type Command
- type Component
- func (c *Component) ConfigSchema() component.ConfigSchema
- func (c *Component) DataFlow() component.FlowMetrics
- func (c *Component) Health() component.HealthStatus
- func (c *Component) Initialize() error
- func (c *Component) InputPorts() []component.Port
- func (c *Component) IsStarted() bool
- func (c *Component) Meta() component.Metadata
- func (c *Component) OutputPorts() []component.Port
- func (c *Component) Start(ctx context.Context) error
- func (c *Component) Stop(_ time.Duration) error
- type ComponentConfig
- type State
Constants ¶
const ( CommandPayloadDomain = "mission" CommandPayloadCategory = "command" CommandPayloadVersion = "v1" )
CommandPayloadDomain / Category / Version is the payload-registry type discriminator for MissionCommand JSON envelopes.
const ( PredicatePhase = "mission.phase" PredicateOwnerOrgID = "mission.owner_org_id" PredicateNote = "mission.note" PredicateAuditSource = "mission.last_transition_source" PredicateAuditAt = "mission.last_transition_at" PredicateAuditFrom = "mission.last_transition_from" PredicateAuditNote = "mission.last_transition_note" )
Predicate names for projection (ADR-049). Manager.Transition writes `mission.phase`; UpdateFromOperator writes `mission.owner_org_id` and `mission.note`; the audit predicates carry source attribution.
const ( PhasePlanning = "planning" PhaseFlying = "flying" PhaseCompleted = "completed" PhaseAborted = "aborted" )
Phases of a mission.
const CommandComponentName = "mission-command"
CommandComponentName is the registered component-factory key.
const EntityIDPattern = "*.*.lifecycle.gcs.mission.*"
EntityIDPattern matches mission entities in the federated graph. Six-segment org.platform.domain.system.type.instance shape per pkg/types.EntityID; the org + platform + instance segments wildcard while domain (`lifecycle`), system (`gcs`), and type (`mission`) pin the canonical mission shape.
const Workflow = "mission"
Workflow is the registered workflow type name.
Variables ¶
var Transitions = lifecycle.Transitions{ PhasePlanning: {PhaseFlying, PhaseAborted}, PhaseFlying: {PhaseCompleted, PhaseAborted}, PhaseCompleted: {}, PhaseAborted: {}, }
Transitions is the declared phase graph for a Mission.
planning ──> flying ──> completed
└──> aborted
flying ──> aborted
completed + aborted are terminal (no out-edges).
Functions ¶
func EntityIDFor ¶
EntityIDFor returns the federated 6-part entity ID for a mission given the standard parts. Exposed as a helper so the e2e scenario / seeder can use the same shape.
func NewComponent ¶
func NewComponent(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
NewComponent is the factory called by the component registry.
func RegisterPayloads ¶
func RegisterPayloads(reg *payloadregistry.Registry) error
RegisterPayloads registers the mission.command.v1 envelope shape.
func WorkflowDeclaration ¶
WorkflowDeclaration returns the lifecycle.Workflow ready to pass to Manager.Register. Centralized here so cmd/e2e-semstreams/main.go + the lifecycle-gateway both see the same schema.
Types ¶
type Command ¶
type Command struct {
OrgID string `json:"org_id"`
Platform string `json:"platform"`
MissionID string `json:"mission_id"`
Command string `json:"command"`
}
Command is a Graphable that targets a mission entity by ID and stamps a single `mission.command` triple. The Subject of every triple is the federated 6-part entity ID composed from OrgID + Platform + MissionID — must match the State.EntityID() of the mission instance the rule should transition.
func (*Command) MarshalJSON ¶
MarshalJSON implements json.Marshaler via the alias-recursion pattern. Required for message.NewBaseMessage to accept Command as a Payload (the Payload interface includes json.Marshaler).
func (*Command) Triples ¶
Triples returns the single command triple. graph-ingest writes this into ENTITY_STATES; the rule engine fires on the predicate.
func (*Command) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler symmetrically.
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component subscribes to a single core-NATS subject, parses JSON commands, and republishes them as BaseMessage-wrapped Graphables to the configured output subject. Output flows through graph-ingest which lands the triple in ENTITY_STATES, where the rule engine picks it up.
func (*Component) ConfigSchema ¶
func (c *Component) ConfigSchema() component.ConfigSchema
ConfigSchema implements component.Discoverable.
func (*Component) DataFlow ¶
func (c *Component) DataFlow() component.FlowMetrics
DataFlow returns a minimal flow metric stub (this processor is e2e-only, not a production hotpath).
func (*Component) Health ¶
func (c *Component) Health() component.HealthStatus
Health reports component health.
func (*Component) Initialize ¶
Initialize is a no-op — subscriptions land in Start.
func (*Component) InputPorts ¶
InputPorts returns the configured input ports.
func (*Component) OutputPorts ¶
OutputPorts returns the configured output ports.
type ComponentConfig ¶
type ComponentConfig struct {
Ports *component.PortConfig `json:"ports"`
OrgID string `json:"org_id"`
Platform string `json:"platform"`
}
ComponentConfig configures the mission-command processor.
type State ¶
type State struct {
EntityIDField string `json:"entity_id" lifecycle:"id"`
PhaseField string `json:"phase" lifecycle:"phase,predicate=mission.phase"`
OwnerOrgID string `json:"owner_org_id,omitempty" lifecycle:"operator_writable,predicate=mission.owner_org_id"`
Note string `json:"note,omitempty" lifecycle:"operator_writable,predicate=mission.note"`
}
State is a lifecycle.Participant for the Mission workflow.
Field tags (ADR-049):
- lifecycle:"id" — identity
- lifecycle:"phase,predicate=mission.phase" — phase triple
- lifecycle:"operator_writable,predicate=mission.*" — patchable via operator API
The projection layer round-trips between the entity's triples in ENTITY_STATES and this struct on every Get / Transition; the Participant is a typed VIEW over triples, not a private blob.
func New ¶
func New() *State
New returns a freshly-initialized State. Apps don't call this on read — Manager.Get projects fresh instances from the registered Schema via reflection. New is here for Create-side callers (e.g. seedMission in cmd/e2e-semstreams/main.go).
func (*State) IsTerminal ¶
IsTerminal returns true when the current phase has no declared out-edges in Transitions.
func (*State) ParentEntityID ¶
ParentEntityID returns "" — missions have no parent workflow in this demo.