Documentation
¶
Index ¶
- Variables
- type BindingTarget
- type CausalStore
- type ClockStamp
- type DOTOptions
- type Event
- type EventExport
- type EventID
- type EventSet
- type EventStore
- type MapTarget
- type MergeResult
- type NodeID
- type PendingEdge
- type Poset
- func (p *Poset) Add(e *Event) error
- func (p *Poset) AddCausal(from, to EventID) error
- func (p *Poset) AddEdge(from, to EventID) error
- func (p *Poset) AddEvent(e *Event) error
- func (p *Poset) AddEventWithCause(e *Event, causes ...EventID) error
- func (p *Poset) All() EventSet
- func (p *Poset) ByName(name string) EventSet
- func (p *Poset) CausalAncestors(id EventID) EventSet
- func (p *Poset) CausalChain(from, to EventID) (EventSet, error)
- func (p *Poset) CausalDescendants(id EventID) EventSet
- func (p *Poset) CreateIncrementalSnapshot(nodeID NodeID, sinceHighWater uint64) *Snapshot
- func (p *Poset) CreateSnapshot(nodeID NodeID) *Snapshot
- func (p *Poset) DOT() string
- func (p *Poset) DOTWithOptions(opts DOTOptions) string
- func (p *Poset) DirectCauses(id EventID) EventSet
- func (p *Poset) DirectEffects(id EventID) EventSet
- func (p *Poset) DirectPredecessors(id EventID) []EventID
- func (p *Poset) DirectSuccessors(id EventID) []EventID
- func (p *Poset) DrainPendingEdges() (int, []error)
- func (p *Poset) Event(id EventID) (*Event, bool)
- func (p *Poset) Events() EventSet
- func (p *Poset) EventsByName(name string) EventSet
- func (p *Poset) Get(id EventID) (*Event, bool)
- func (p *Poset) HasPath(from, to EventID) bool
- func (p *Poset) IsCausallyBefore(a, b EventID) bool
- func (p *Poset) IsCausallyIndependent(a, b EventID) bool
- func (p *Poset) Leaves() EventSet
- func (p *Poset) Len() int
- func (p *Poset) MarshalJSON() ([]byte, error)
- func (p *Poset) MergeSnapshot(snap *Snapshot) (*MergeResult, error)
- func (p *Poset) Mermaid() string
- func (p *Poset) PendingEdgeCount() int
- func (p *Poset) Roots() EventSet
- func (p *Poset) Stats() PosetStats
- func (p *Poset) String() string
- func (p *Poset) ToTraceSpans() []TraceSpan
- func (p *Poset) TopologicalSort() []*Event
- func (p *Poset) UnmarshalJSON(data []byte) error
- func (p *Poset) Validate() []error
- type PosetBuilder
- type PosetExport
- type PosetQuerier
- type PosetReadWriter
- type PosetStats
- type Snapshot
- type TraceSpan
- type VectorClock
Constants ¶
This section is empty.
Variables ¶
var ( ErrEventExists = errors.New("event already exists in poset") ErrEventNotFound = errors.New("event not found in poset") ErrCyclicCausal = errors.New("adding this edge would create a causal cycle") ErrNoPath = errors.New("no causal path exists between events") ErrSelfCausal = errors.New("an event cannot causally precede itself") )
Functions ¶
This section is empty.
Types ¶
type BindingTarget ¶
BindingTarget is a placeholder interface for future Rapide Binding support. In the Rapide language, Bindings allow different component interfaces to be connected dynamically at runtime. A binding maps event names from one interface to another, enabling modular composition of architectures.
This interface is reserved and will be implemented in a future version.
type CausalStore ¶
type CausalStore interface {
AddEdge(from, to EventID) error
DirectPredecessors(id EventID) []EventID
DirectSuccessors(id EventID) []EventID
HasPath(from, to EventID) bool // transitive reachability
}
CausalStore defines the interface for storing and querying causal edges.
type ClockStamp ¶
type ClockStamp struct {
Lamport uint64 // Logical Lamport timestamp for causal ordering
WallTime time.Time // Wall clock time for temporal ordering
Vector VectorClock // Optional vector clock for distributed mode (nil = single-node)
}
ClockStamp holds both logical and physical time for an event.
func (ClockStamp) Before ¶
func (c ClockStamp) Before(other ClockStamp) bool
Before reports whether this ClockStamp is causally before other, using Lamport ordering.
type DOTOptions ¶
type DOTOptions struct {
ColorBySource bool // different colors per component
ShowParams bool // include param values in labels
ShowTimestamps bool // include Lamport timestamps
HighlightPath []EventID // highlight a specific causal path
ClusterBySource bool // group nodes by source component in subgraphs
}
DOTOptions configures the DOT export.
type Event ¶
type Event struct {
ID EventID
Name string
Params map[string]any
Clock ClockStamp
Source string
Immutable bool
}
Event is the atomic unit of the gorapide system. An Event is an immutable, uniquely identifiable tuple of values that exists within causal and temporal ordering relations.
func NewEvent ¶
NewEvent creates a new Event with an auto-generated ID and WallTime set to now. Lamport starts at 0.
func (*Event) Freeze ¶
func (e *Event) Freeze()
Freeze marks the event as immutable. Once frozen, the Params map should not be modified. Freeze replaces the internal Params map with a defensive copy to discourage further mutation.
func (*Event) Param ¶
Param retrieves a parameter value by key. Returns the value and whether the key was present.
func (*Event) ParamInt ¶
ParamInt returns the int value of a parameter, or 0 if the key is missing or not an int.
func (*Event) ParamString ¶
ParamString returns the string value of a parameter, or "" if the key is missing or not a string.
type EventExport ¶
type EventExport struct {
ID string `json:"id"`
Name string `json:"name"`
Params map[string]any `json:"params"`
Source string `json:"source"`
Lamport uint64 `json:"lamport"`
WallTime string `json:"wall_time"`
VectorClock map[string]uint64 `json:"vector_clock,omitempty"`
}
EventExport is the JSON-serializable representation of an Event.
type EventID ¶
type EventID string
EventID is a unique identifier for an event, represented as a UUID string.
func NewEventID ¶
func NewEventID() EventID
NewEventID generates a new random UUID-based EventID using crypto/rand.
type EventSet ¶
type EventSet []*Event
EventSet is an ordered collection of events with helper methods.
func (EventSet) Filter ¶
Filter returns a new EventSet containing only events for which fn returns true.
type EventStore ¶
type EventStore interface {
Add(e *Event) error
Get(id EventID) (*Event, bool)
All() EventSet
ByName(name string) EventSet
Len() int
}
EventStore defines the interface for storing and retrieving events.
type MapTarget ¶
MapTarget is a placeholder interface for future Rapide Map support. In the Rapide language, Maps define relationships between architectures, translating events from one architecture's vocabulary into another's. A MapTarget transforms a source event into zero or more target events, enabling cross-architecture event translation and composition.
This interface is reserved and will be implemented in a future version.
type MergeResult ¶
type MergeResult struct {
EventsAdded int
EventsSkipped int
EdgesAdded int
EdgesSkipped int
EdgesPending int
}
MergeResult summarizes the outcome of merging a Snapshot into a Poset.
type PendingEdge ¶
PendingEdge represents a causal edge whose endpoints may not yet be present in the local poset.
type Poset ¶
type Poset struct {
// contains filtered or unexported fields
}
Poset is a Partially Ordered Event Set that stores events and their causal and temporal ordering relationships. It is safe for concurrent use.
func (*Poset) AddCausal ¶
AddCausal establishes that event 'from' causally precedes event 'to'. It validates both events exist, rejects self-edges and cycles, and updates the 'to' event's Lamport timestamp to max(to.Lamport, from.Lamport+1).
func (*Poset) AddEvent ¶
AddEvent adds an event to the poset, freezes it, and assigns a Lamport timestamp. Returns an error if an event with the same ID already exists.
func (*Poset) AddEventWithCause ¶
AddEventWithCause adds an event and establishes causal edges from all specified causes to the new event. This is the primary way events are added during execution.
func (*Poset) CausalAncestors ¶
CausalAncestors returns all transitive causal predecessors of the event.
func (*Poset) CausalChain ¶
CausalChain returns all events on any causal path from 'from' to 'to', including 'from' and 'to' themselves. Returns an error if no causal path exists.
func (*Poset) CausalDescendants ¶
CausalDescendants returns all transitive causal successors of the event.
func (*Poset) CreateIncrementalSnapshot ¶
CreateIncrementalSnapshot builds a Snapshot containing only events with Lamport timestamps >= sinceHighWater, along with edges between those events.
func (*Poset) CreateSnapshot ¶
CreateSnapshot builds a full Snapshot of the current Poset state containing all events and edges.
func (*Poset) DOTWithOptions ¶
func (p *Poset) DOTWithOptions(opts DOTOptions) string
DOTWithOptions exports the poset as Graphviz DOT with configurable options.
func (*Poset) DirectCauses ¶
DirectCauses returns the immediate causal predecessors of the event (one hop back).
func (*Poset) DirectEffects ¶
DirectEffects returns the immediate causal successors of the event (one hop forward).
func (*Poset) DirectPredecessors ¶
DirectPredecessors implements CausalStore. Returns the EventIDs of immediate causal predecessors.
func (*Poset) DirectSuccessors ¶
DirectSuccessors implements CausalStore. Returns the EventIDs of immediate causal successors.
func (*Poset) DrainPendingEdges ¶
DrainPendingEdges attempts to resolve all buffered pending edges whose endpoints are now present in the poset. Returns the count of resolved edges and any errors encountered during resolution.
func (*Poset) EventsByName ¶
EventsByName returns all events with the given name.
func (*Poset) HasPath ¶
HasPath implements CausalStore. Reports whether there is a transitive causal path from 'from' to 'to'.
func (*Poset) IsCausallyBefore ¶
IsCausallyBefore reports whether event a causally precedes event b (transitive).
func (*Poset) IsCausallyIndependent ¶
IsCausallyIndependent reports whether neither a <c b nor b <c a.
func (*Poset) MarshalJSON ¶
MarshalJSON implements json.Marshaler for Poset.
func (*Poset) MergeSnapshot ¶
func (p *Poset) MergeSnapshot(snap *Snapshot) (*MergeResult, error)
MergeSnapshot integrates a remote Snapshot into the local Poset. Events are sorted by Lamport before insertion so that causal ordering is preserved. Duplicate events are skipped. Edges whose endpoints are missing are buffered as pending edges for later resolution.
func (*Poset) PendingEdgeCount ¶
PendingEdgeCount returns the number of buffered pending edges.
func (*Poset) Stats ¶
func (p *Poset) Stats() PosetStats
Stats returns aggregate statistics about the poset.
func (*Poset) ToTraceSpans ¶
ToTraceSpans converts poset events to OpenTelemetry-compatible trace spans. All spans share the same TraceID. SpanID maps to EventID. ParentID maps to the first direct causal predecessor (lowest Lamport).
func (*Poset) TopologicalSort ¶
TopologicalSort returns events in a valid causal order where every event appears after all of its causal predecessors. Uses Kahn's algorithm.
func (*Poset) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for Poset.
type PosetBuilder ¶
type PosetBuilder struct {
// contains filtered or unexported fields
}
PosetBuilder provides a fluent API for constructing posets concisely.
func (*PosetBuilder) CausedBy ¶
func (b *PosetBuilder) CausedBy(names ...string) *PosetBuilder
CausedBy declares that the last added event was caused by the named events. Names refer to previously added events. If multiple events share a name, the most recently added one with that name is used.
func (*PosetBuilder) Done ¶
func (b *PosetBuilder) Done() (*Poset, error)
Done finalizes the builder and returns the constructed Poset.
func (*PosetBuilder) Event ¶
func (b *PosetBuilder) Event(name string, params ...any) *PosetBuilder
Event adds an event with the given name and optional key-value parameter pairs.
func (*PosetBuilder) MustDone ¶
func (b *PosetBuilder) MustDone() *Poset
MustDone finalizes the builder and returns the Poset, panicking on error.
func (*PosetBuilder) Source ¶
func (b *PosetBuilder) Source(component string) *PosetBuilder
Source sets the source component for subsequent events.
type PosetExport ¶
type PosetExport struct {
Events []EventExport `json:"events"`
CausalEdges [][]string `json:"causal_edges"`
Metadata map[string]string `json:"metadata"`
}
PosetExport is the JSON-serializable representation of a Poset.
type PosetQuerier ¶
type PosetQuerier interface {
IsCausallyBefore(a, b EventID) bool
IsCausallyIndependent(a, b EventID) bool
CausalAncestors(id EventID) EventSet
CausalDescendants(id EventID) EventSet
CausalChain(from, to EventID) (EventSet, error)
Roots() EventSet
Leaves() EventSet
TopologicalSort() []*Event
}
PosetQuerier defines read-only causal query operations on a poset.
type PosetReadWriter ¶
type PosetReadWriter interface {
EventStore
CausalStore
PosetQuerier
AddEventWithCause(e *Event, causes ...EventID) error
Validate() []error
Stats() PosetStats
DOT() string
}
PosetReadWriter combines event storage, causal storage, and query capabilities into a single interface representing a full poset.
type PosetStats ¶
type PosetStats struct {
EventCount int
EdgeCount int
RootCount int
LeafCount int
MaxDepth int // longest causal chain
AvgFanOut float64 // average number of direct effects per event
ComponentCount int // number of distinct Source values
}
PosetStats holds aggregate statistics about a Poset.
type Snapshot ¶
type Snapshot struct {
NodeID NodeID `json:"node_id"`
Events []EventExport `json:"events"`
CausalEdges [][]string `json:"causal_edges"`
HighWater uint64 `json:"high_water"`
}
Snapshot is a serializable representation of a subset of a Poset, used for shipping events between nodes.
type TraceSpan ¶
type TraceSpan struct {
TraceID string
SpanID string
ParentID string
Name string
StartTime time.Time
EndTime time.Time
Attributes map[string]string
}
TraceSpan represents an OpenTelemetry-compatible trace span derived from a poset event. Causal edges become parent-child span relationships.
type VectorClock ¶
VectorClock tracks logical time across multiple nodes. A nil VectorClock indicates single-node mode (backward compatible).
func (VectorClock) Before ¶
func (vc VectorClock) Before(other VectorClock) bool
Before reports whether vc is strictly causally before other. This is true iff for every node k, vc[k] <= other[k], and there exists at least one node k where vc[k] < other[k]. A nil receiver is treated as having all entries equal to 0.
func (VectorClock) Clone ¶
func (vc VectorClock) Clone() VectorClock
Clone returns a deep copy of the VectorClock. A nil receiver returns nil.
func (VectorClock) Concurrent ¶
func (vc VectorClock) Concurrent(other VectorClock) bool
Concurrent reports whether vc and other are causally concurrent, meaning neither is before the other and they are not equal. Two nil/empty vectors are considered equal, not concurrent (returns false).
func (VectorClock) Increment ¶
func (vc VectorClock) Increment(node NodeID) VectorClock
Increment returns a NEW VectorClock with the given node's counter incremented by one. It does not mutate the original.
func (VectorClock) Merge ¶
func (vc VectorClock) Merge(other VectorClock) VectorClock
Merge returns a NEW VectorClock containing the pointwise maximum of vc and other. Neither receiver nor argument is mutated.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package constraint implements Rapide pattern constraints for verifying acceptable and unacceptable event patterns in a poset.
|
Package constraint implements Rapide pattern constraints for verifying acceptable and unacceptable event patterns in a poset. |
|
examples
|
|
|
ato_scanner
command
Command ato_scanner demonstrates a security scanning pipeline modeled as a Rapide architecture using gorapide.
|
Command ato_scanner demonstrates a security scanning pipeline modeled as a Rapide architecture using gorapide. |
|
Package export provides format utilities for working with exported poset data.
|
Package export provides format utilities for working with exported poset data. |
|
Package pattern implements the Rapide Event Pattern Language.
|
Package pattern implements the Rapide Event Pattern Language. |