fsm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package fsm provides protocol state machine extraction and visualization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	Name    string `json:"name"`
	Initial bool   `json:"initial,omitempty"`
	Final   bool   `json:"final,omitempty"`
}

State represents a protocol state.

type StateMachine

type StateMachine struct {
	Protocol    string       `json:"protocol"`
	States      []State      `json:"states"`
	Transitions []Transition `json:"transitions"`
}

StateMachine represents a protocol state machine.

func NewStateMachine

func NewStateMachine(protocol string) *StateMachine

NewStateMachine creates a new state machine.

func (*StateMachine) AddState

func (sm *StateMachine) AddState(name string, initial, final bool)

AddState adds a state.

func (*StateMachine) AddTransition

func (sm *StateMachine) AddTransition(from, to, event string)

AddTransition adds a transition.

func (*StateMachine) Coverage

func (sm *StateMachine) Coverage(observed []string) float64

Coverage calculates state coverage from observed transitions.

func (*StateMachine) ToDOT

func (sm *StateMachine) ToDOT() string

ToDOT generates a Graphviz DOT diagram.

func (*StateMachine) ToMermaid

func (sm *StateMachine) ToMermaid() string

ToMermaid generates a Mermaid state diagram.

type Transition

type Transition struct {
	From      string `json:"from"`
	To        string `json:"to"`
	Event     string `json:"event"`
	Condition string `json:"condition,omitempty"`
}

Transition represents a state transition.

Jump to

Keyboard shortcuts

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