Documentation
¶
Overview ¶
Package orchestrator implements the DIP Heartbeat Orchestrator.
The orchestrator runs a background loop with 4 modules:
- Auto-Discovery — monitors configured peer endpoints for new Merkle-compatible nodes
- Sync Manager — auto-syncs L0-L1 facts between trusted peers on changes
- Stability Watchdog — monitors entropy and triggers apoptosis recovery
- Jittered Heartbeat — randomizes intervals to avoid detection patterns
The orchestrator works with domain-level components directly (not through MCP tools). It is started as a goroutine from main.go and runs until context cancellation.
Index ¶
- func WriteDefaultConfig(path string) error
- type Config
- type HeartbeatResult
- type JSONConfig
- type Orchestrator
- func (o *Orchestrator) AlertBus() *alert.Bus
- func (o *Orchestrator) History() []HeartbeatResult
- func (o *Orchestrator) IsRunning() bool
- func (o *Orchestrator) SetSynapseStore(store synapse.SynapseStore)
- func (o *Orchestrator) Start(ctx context.Context)
- func (o *Orchestrator) Stats() map[string]interface{}
- func (o *Orchestrator) Status() OrchestratorStatus
- type OrchestratorStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteDefaultConfig ¶
WriteDefaultConfig writes a default config.json to the given path.
Types ¶
type Config ¶
type Config struct {
// HeartbeatInterval is the base interval between heartbeat cycles.
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
// JitterPercent is the percentage of HeartbeatInterval to add/subtract randomly.
// e.g., 30 means ±30% jitter around the base interval.
JitterPercent int `json:"jitter_percent"`
// EntropyThreshold triggers apoptosis recovery when exceeded (0.0-1.0).
EntropyThreshold float64 `json:"entropy_threshold"`
// KnownPeers are pre-configured peer genome hashes for auto-discovery.
// Format: "node_name:genome_hash"
KnownPeers []string `json:"known_peers"`
// SyncOnChange triggers sync when new local facts are detected.
SyncOnChange bool `json:"sync_on_change"`
// MaxSyncBatchSize limits facts per sync payload.
MaxSyncBatchSize int `json:"max_sync_batch_size"`
}
Config holds orchestrator configuration.
func LoadConfigFromFile ¶
LoadConfigFromFile reads .rlm/config.json and returns a Config. Missing or invalid file → returns defaults silently.
type HeartbeatResult ¶
type HeartbeatResult struct {
Cycle int `json:"cycle"`
StartedAt time.Time `json:"started_at"`
Duration time.Duration `json:"duration"`
PeersDiscovered int `json:"peers_discovered"`
FactsSynced int `json:"facts_synced"`
EntropyLevel float64 `json:"entropy_level"`
ApoptosisTriggered bool `json:"apoptosis_triggered"`
GenomeIntact bool `json:"genome_intact"`
GenesHealed int `json:"genes_healed"`
FactsExpired int `json:"facts_expired"`
FactsArchived int `json:"facts_archived"`
SynapsesCreated int `json:"synapses_created"` // v3.4: Module 9
NextInterval time.Duration `json:"next_interval"`
Errors []string `json:"errors,omitempty"`
}
HeartbeatResult records what happened in one heartbeat cycle.
type JSONConfig ¶
type JSONConfig struct {
HeartbeatIntervalSec int `json:"heartbeat_interval_sec,omitempty"`
JitterPercent int `json:"jitter_percent,omitempty"`
EntropyThreshold float64 `json:"entropy_threshold,omitempty"`
MaxSyncBatchSize int `json:"max_sync_batch_size,omitempty"`
SynapseIntervalMult int `json:"synapse_interval_multiplier,omitempty"` // default: 12
}
JSONConfig is the v3.4 file-based configuration for the Orchestrator. Loaded from .rlm/config.json. Overrides compiled defaults.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator runs the DIP heartbeat pipeline.
func NewWithAlerts ¶
func NewWithAlerts(cfg Config, peerReg *peer.Registry, store memory.FactStore, bus *alert.Bus) *Orchestrator
NewWithAlerts creates an orchestrator with an alert bus for DIP-Watcher.
func (*Orchestrator) AlertBus ¶
func (o *Orchestrator) AlertBus() *alert.Bus
AlertBus returns the alert bus (may be nil).
func (*Orchestrator) History ¶
func (o *Orchestrator) History() []HeartbeatResult
History returns recent heartbeat results.
func (*Orchestrator) IsRunning ¶
func (o *Orchestrator) IsRunning() bool
IsRunning returns whether the orchestrator is active.
func (*Orchestrator) SetSynapseStore ¶
func (o *Orchestrator) SetSynapseStore(store synapse.SynapseStore)
SetSynapseStore enables Module 9 (Synapse Scanner) at runtime.
func (*Orchestrator) Start ¶
func (o *Orchestrator) Start(ctx context.Context)
Start begins the heartbeat loop. Blocks until context is cancelled.
func (*Orchestrator) Stats ¶
func (o *Orchestrator) Stats() map[string]interface{}
Stats returns current orchestrator status.
func (*Orchestrator) Status ¶
func (o *Orchestrator) Status() OrchestratorStatus
Status returns current orchestrator state (v3.4: observability).
type OrchestratorStatus ¶
type OrchestratorStatus struct {
Running bool `json:"running"`
Cycle int `json:"cycle"`
Config Config `json:"config"`
LastResult *HeartbeatResult `json:"last_result,omitempty"`
HistorySize int `json:"history_size"`
HasSynapseStore bool `json:"has_synapse_store"`
}
OrchestratorStatus is the v3.4 observability snapshot.