colony

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package colony defines the core data types for the Aether colony state system. All types are designed for exact round-trip compatibility with the COLONY_STATE.json schema used by the shell-based colony implementation.

Index

Constants

View Source
const (
	PhasePending    = "pending"
	PhaseReady      = "ready"
	PhaseInProgress = "in_progress"
	PhaseCompleted  = "completed"
)

Phase status constants.

View Source
const (
	TaskPending    = "pending"
	TaskCompleted  = "completed"
	TaskInProgress = "in_progress"
)

Task status constants.

Variables

View Source
var ErrInvalidTransition = fmt.Errorf("invalid state transition")

ErrInvalidTransition is returned when a state transition is not allowed.

Functions

func AdvancePhase

func AdvancePhase(currentPhase int, phases []Phase) (int, error)

AdvancePhase finds the next pending phase after currentPhase, marks it as ready, and returns its ID. Returns an error if no pending phase exists or if currentPhase is beyond the phases array.

func Transition

func Transition(current, target State) error

Transition validates and returns the target state if the transition from current to target is legal. Returns ErrInvalidTransition if not allowed.

Types

type ColonyState

type ColonyState struct {
	Version            string      `json:"version"`
	Goal               *string     `json:"goal"`
	ColonyName         *string     `json:"colony_name"`
	ColonyVersion      int         `json:"colony_version"`
	State              State       `json:"state"`
	CurrentPhase       int         `json:"current_phase"`
	SessionID          *string     `json:"session_id"`
	InitializedAt      *time.Time  `json:"initialized_at"`
	BuildStartedAt     *time.Time  `json:"build_started_at"`
	Plan               Plan        `json:"plan"`
	Memory             Memory      `json:"memory"`
	Errors             Errors      `json:"errors"`
	Signals            []Signal    `json:"signals"`
	Graveyards         []Graveyard `json:"graveyards"`
	Events             []string    `json:"events"`
	ColonyDepth        string      `json:"colony_depth,omitempty"`
	Milestone          string      `json:"milestone"`
	MilestoneUpdatedAt *string     `json:"milestone_updated_at,omitempty"`
}

ColonyState is the top-level colony state matching COLONY_STATE.json.

type ConstraintsFile

type ConstraintsFile struct{}

ConstraintsFile represents the currently empty constraints.json. The real file is `{}`. If future data adds fields, the type can be extended.

type Decision

type Decision struct {
	ID        string `json:"id"`
	Phase     int    `json:"phase"`
	Claim     string `json:"claim"`
	Rationale string `json:"rationale"`
	Timestamp string `json:"timestamp"`
}

Decision represents a decision made during the colony lifecycle.

type ErrorRecord

type ErrorRecord struct {
	ID          string  `json:"id"`
	Category    string  `json:"category"`
	Severity    string  `json:"severity"`
	Description string  `json:"description"`
	RootCause   *string `json:"root_cause"`
	Phase       *int    `json:"phase"`
	TaskID      *string `json:"task_id"`
	Timestamp   string  `json:"timestamp"`
}

ErrorRecord represents a single error event.

type Errors

type Errors struct {
	Records         []ErrorRecord    `json:"records"`
	FlaggedPatterns []FlaggedPattern `json:"flagged_patterns"`
}

Errors holds error records and flagged patterns.

type FlagEntry

type FlagEntry struct {
	ID          string `json:"id"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Phase       *int   `json:"phase"`
	Source      string `json:"source"`
	CreatedAt   string `json:"created_at"`
	Resolved    bool   `json:"resolved"`
}

FlagEntry represents a single pending decision in pending-decisions.json.

type FlaggedPattern

type FlaggedPattern struct {
	Pattern   string     `json:"pattern"`
	Count     int        `json:"count"`
	FirstSeen *time.Time `json:"first_seen"`
	LastSeen  *time.Time `json:"last_seen"`
}

FlaggedPattern represents a recurring error pattern.

type FlagsFile

type FlagsFile struct {
	Version   string      `json:"version"`
	Decisions []FlagEntry `json:"decisions"`
}

FlagsFile represents the top-level pending-decisions.json file.

type Graveyard

type Graveyard struct {
	ID             string  `json:"id"`
	File           string  `json:"file"`
	AntName        string  `json:"ant_name"`
	TaskID         string  `json:"task_id"`
	Phase          *int    `json:"phase"`
	FailureSummary string  `json:"failure_summary"`
	Function       *string `json:"function"`
	Line           *int    `json:"line"`
	Timestamp      string  `json:"timestamp"`
}

Graveyard marks a file where a builder has failed.

type Instinct

type Instinct struct {
	ID           string   `json:"id"`
	Trigger      string   `json:"trigger"`
	Action       string   `json:"action"`
	Confidence   float64  `json:"confidence"`
	Status       string   `json:"status"`
	Domain       string   `json:"domain"`
	Source       string   `json:"source"`
	Evidence     []string `json:"evidence"`
	Tested       bool     `json:"tested"`
	CreatedAt    string   `json:"created_at"`
	LastApplied  *string  `json:"last_applied"`
	Applications int      `json:"applications"`
	Successes    int      `json:"successes"`
	Failures     int      `json:"failures"`
}

Instinct represents a learned behavioral pattern.

type InstinctEntry

type InstinctEntry struct {
	ID                 string             `json:"id"`
	Trigger            string             `json:"trigger"`
	Action             string             `json:"action"`
	Domain             string             `json:"domain"`
	TrustScore         float64            `json:"trust_score"`
	TrustTier          string             `json:"trust_tier"`
	Confidence         float64            `json:"confidence"`
	Provenance         InstinctProvenance `json:"provenance"`
	ApplicationHistory []interface{}      `json:"application_history"`
	RelatedInstincts   []interface{}      `json:"related_instincts"`
	Archived           bool               `json:"archived"`
}

InstinctEntry represents a single instinct in the standalone instincts.json file. This is the richer schema managed by instinct-store.sh, distinct from the simpler Instinct type embedded in ColonyState.Memory.Instincts.

type InstinctProvenance

type InstinctProvenance struct {
	Source           string  `json:"source"`
	SourceType       string  `json:"source_type"`
	Evidence         string  `json:"evidence"`
	CreatedAt        string  `json:"created_at"`
	LastApplied      *string `json:"last_applied"`
	ApplicationCount int     `json:"application_count"`
}

InstinctProvenance tracks the origin and application history of an instinct.

type InstinctsFile

type InstinctsFile struct {
	Version   string          `json:"version"`
	Instincts []InstinctEntry `json:"instincts"`
}

InstinctsFile represents the standalone instincts.json file.

type Learning

type Learning struct {
	Claim       string  `json:"claim"`
	Status      string  `json:"status"`
	Tested      bool    `json:"tested"`
	Evidence    string  `json:"evidence"`
	DisprovenBy *string `json:"disproven_by"`
}

Learning represents a single learned claim.

type LearningFile

type LearningFile struct {
	Observations []Observation `json:"observations"`
}

LearningFile represents the top-level learning-observations.json file.

type Memory

type Memory struct {
	PhaseLearnings []PhaseLearning `json:"phase_learnings"`
	Decisions      []Decision      `json:"decisions"`
	Instincts      []Instinct      `json:"instincts"`
}

Memory holds colony learning, decisions, and instincts.

type MiddenArchivedSignal

type MiddenArchivedSignal struct {
	ID                 string          `json:"id"`
	Type               string          `json:"type"`
	Priority           string          `json:"priority"`
	Source             string          `json:"source"`
	CreatedAt          string          `json:"created_at"`
	ExpiresAt          *string         `json:"expires_at,omitempty"`
	Active             bool            `json:"active"`
	Strength           *float64        `json:"strength,omitempty"`
	Reason             *string         `json:"reason,omitempty"`
	Content            json.RawMessage `json:"content"`
	ContentHash        *string         `json:"content_hash,omitempty"`
	ReinforcementCount *int            `json:"reinforcement_count,omitempty"`
	ArchivedAt         *string         `json:"archived_at,omitempty"`
	Tags               []PheromoneTag  `json:"tags,omitempty"`
	Scope              *PheromoneScope `json:"scope,omitempty"`
}

MiddenArchivedSignal represents an archived pheromone signal in midden.json. Signals and entries are different types with different fields.

type MiddenEntry

type MiddenEntry struct {
	ID                string   `json:"id"`
	Timestamp         string   `json:"timestamp"`
	Category          string   `json:"category"`
	Source            string   `json:"source"`
	Message           string   `json:"message"`
	Reviewed          bool     `json:"reviewed"`
	Acknowledged      *bool    `json:"acknowledged,omitempty"`
	AcknowledgedAt    *string  `json:"acknowledged_at,omitempty"`
	AcknowledgeReason *string  `json:"acknowledge_reason,omitempty"`
	Tags              []string `json:"tags,omitempty"`
}

MiddenEntry represents a single failure record in midden.json.

type MiddenFile

type MiddenFile struct {
	Version         string                 `json:"version"`
	ArchivedAtCount *int                   `json:"archived_at_count,omitempty"`
	Signals         []MiddenArchivedSignal `json:"signals"`
	Entries         []MiddenEntry          `json:"entries"`
	EntryCount      *int                   `json:"entry_count,omitempty"`
	SpawnMetrics    *MiddenSpawnMetrics    `json:"spawn_metrics,omitempty"`
}

MiddenFile represents the top-level midden.json file.

type MiddenSpawnMetrics

type MiddenSpawnMetrics struct {
	TotalSpawned  int `json:"total_spawned"`
	Completed     int `json:"completed"`
	Failed        int `json:"failed"`
	EfficiencyPct int `json:"efficiency_pct"`
}

MiddenSpawnMetrics tracks spawn efficiency metrics in midden.json.

type Observation

type Observation struct {
	ContentHash      string   `json:"content_hash"`
	Content          string   `json:"content"`
	WisdomType       string   `json:"wisdom_type"`
	ObservationCount int      `json:"observation_count"`
	FirstSeen        string   `json:"first_seen"`
	LastSeen         string   `json:"last_seen"`
	Colonies         []string `json:"colonies"`
	TrustScore       *float64 `json:"trust_score,omitempty"`
	SourceType       string   `json:"source_type,omitempty"`
	EvidenceType     string   `json:"evidence_type,omitempty"`
	CompressionLevel int      `json:"compression_level,omitempty"`
}

Observation represents a single learning observation in learning-observations.json.

type Phase

type Phase struct {
	ID              int      `json:"id"`
	Name            string   `json:"name"`
	Description     string   `json:"description"`
	Status          string   `json:"status"`
	Tasks           []Task   `json:"tasks"`
	SuccessCriteria []string `json:"success_criteria"`
}

Phase represents a single phase in the colony plan.

type PhaseLearning

type PhaseLearning struct {
	ID        string     `json:"id"`
	Phase     int        `json:"phase"`
	PhaseName string     `json:"phase_name"`
	Learnings []Learning `json:"learnings"`
	Timestamp string     `json:"timestamp"`
}

PhaseLearning captures learnings from a specific phase.

type PheromoneFile

type PheromoneFile struct {
	Signals  []PheromoneSignal `json:"signals"`
	Version  *string           `json:"version,omitempty"`
	ColonyID *string           `json:"colony_id,omitempty"`
}

PheromoneFile represents the top-level pheromones.json file.

type PheromoneScope

type PheromoneScope struct {
	Global bool `json:"global"`
}

PheromoneScope defines the scope of a pheromone signal.

type PheromoneSignal

type PheromoneSignal struct {
	ID                 string          `json:"id"`
	Type               string          `json:"type"`
	Priority           string          `json:"priority"`
	Source             string          `json:"source"`
	CreatedAt          string          `json:"created_at"`
	ExpiresAt          *string         `json:"expires_at,omitempty"`
	Active             bool            `json:"active"`
	Strength           *float64        `json:"strength,omitempty"`
	Reason             *string         `json:"reason,omitempty"`
	Content            json.RawMessage `json:"content"`
	ContentHash        *string         `json:"content_hash,omitempty"`
	ReinforcementCount *int            `json:"reinforcement_count,omitempty"`
	ArchivedAt         *string         `json:"archived_at,omitempty"`
	Tags               []PheromoneTag  `json:"tags,omitempty"`
	Scope              *PheromoneScope `json:"scope,omitempty"`
}

PheromoneSignal represents a single pheromone signal in pheromones.json. Content uses json.RawMessage to preserve nested JSON objects like {"text": "..."} without double-escaping.

type PheromoneTag

type PheromoneTag struct {
	Value    string  `json:"value"`
	Weight   float64 `json:"weight"`
	Category string  `json:"category"`
}

PheromoneTag represents a categorization tag on a pheromone signal.

type Plan

type Plan struct {
	GeneratedAt *time.Time `json:"generated_at"`
	Confidence  *float64   `json:"confidence"`
	Phases      []Phase    `json:"phases"`
}

Plan holds the generated phase plan.

type SessionFile

type SessionFile struct {
	SessionID        string   `json:"session_id"`
	StartedAt        string   `json:"started_at"`
	LastCommand      string   `json:"last_command"`
	LastCommandAt    string   `json:"last_command_at"`
	ColonyGoal       string   `json:"colony_goal"`
	CurrentPhase     int      `json:"current_phase"`
	CurrentMilestone string   `json:"current_milestone"`
	SuggestedNext    string   `json:"suggested_next"`
	ContextCleared   bool     `json:"context_cleared"`
	BaselineCommit   string   `json:"baseline_commit"`
	ResumedAt        *string  `json:"resumed_at"`
	ActiveTodos      []string `json:"active_todos"`
	Summary          string   `json:"summary"`
}

SessionFile represents the top-level session.json file.

type Signal

type Signal struct {
	ID        string `json:"id"`
	Type      string `json:"type"`
	Priority  string `json:"priority"`
	Source    string `json:"source"`
	Content   string `json:"content"`
	Active    bool   `json:"active"`
	CreatedAt string `json:"created_at"`
}

Signal represents a colony signal (deprecated in favor of pheromones.json).

type State

type State string

State represents the lifecycle state of a colony.

const (
	StateREADY     State = "READY"
	StateEXECUTING State = "EXECUTING"
	StateBUILT     State = "BUILT"
	StateCOMPLETED State = "COMPLETED"
)

type Task

type Task struct {
	ID              *string  `json:"id"`
	Goal            string   `json:"goal"`
	Status          string   `json:"status"`
	Constraints     []string `json:"constraints,omitempty"`
	Hints           []string `json:"hints,omitempty"`
	SuccessCriteria []string `json:"success_criteria,omitempty"`
	DependsOn       []string `json:"depends_on,omitempty"`
}

Task represents a single task within a phase.

Jump to

Keyboard shortcuts

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