memory

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: 16 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 memory implements the wisdom pipeline including trust scoring, observation capture, instinct promotion, and memory consolidation.

Index

Constants

This section is empty.

Variables

View Source
var WisdomThresholds = map[string]WisdomThresholdEntry{
	"build_learning": {0, 0},
	"instinct":       {0, 0},
	"philosophy":     {1, 3},
	"pattern":        {1, 1},
	"redirect":       {1, 2},
	"stack":          {1, 2},
	"decree":         {0, 0},
	"failure":        {1, 2},
}

WisdomThresholds maps wisdom types to their promotion thresholds.

Functions

func CheckPromotion

func CheckPromotion(obs colony.Observation) (bool, string)

CheckPromotion checks if an observation should be promoted to an instinct.

func Decay

func Decay(score float64, days int) float64

Decay applies half-life decay to an existing trust score. Source: trust-scoring.sh decay logic

func RecurrenceConfidence

func RecurrenceConfidence(observationCount int) float64

RecurrenceConfidence calculates the confidence based on observation count. Source: learning.sh lines 469-475 Formula: min(0.7 + (observationCount - 1) * 0.05, 0.9)

func Tier

func Tier(score float64) (string, int)

Tier returns the trust tier name and index for a given score. Source: trust-scoring.sh lines 296-330

Types

type ConsolidationResult

type ConsolidationResult struct {
	InstinctsDecayed    int
	InstinctsArchived   int
	ObservationsDecayed int
	PromotionCandidates []string // content hashes of observations eligible for promotion
	QueenEligible       []string // instinct IDs eligible for QUEEN.md promotion
	Errors              []error
}

ConsolidationResult holds the outcome of a phase-end consolidation run.

type ConsolidationService

type ConsolidationService struct {
	// contains filtered or unexported fields
}

ConsolidationService runs phase-end consolidation: decay, archive, and check promotions. Source: Shell consolidation.sh lines 23-127

func NewConsolidationService

func NewConsolidationService(store *storage.Store, bus *events.Bus, queenPath string, colonyName string) *ConsolidationService

NewConsolidationService creates a new consolidation service.

func (*ConsolidationService) Run

Run executes the full consolidation pipeline: decay instincts, archive low-trust, decay observations, check promotion candidates, identify queen-eligible instincts. Each step is non-blocking: failures are recorded in result.Errors but do not stop the pipeline.

type ObservationResult

type ObservationResult struct {
	Observation       colony.Observation
	IsNew             bool
	PromotionEligible bool
	PromotionReason   string
}

ObservationResult holds the result of an observation capture.

type ObservationService

type ObservationService struct {
	// contains filtered or unexported fields
}

ObservationService captures and stores observations with trust scoring. Source: Shell learning.sh lines 97-381

func NewObservationService

func NewObservationService(store *storage.Store, bus *events.Bus) *ObservationService

NewObservationService creates a new observation service.

func (*ObservationService) Capture

func (s *ObservationService) Capture(ctx context.Context, content, wisdomType, colonyName string) (*ObservationResult, error)

Capture captures a new observation with default source/evidence types. Uses source_type="observation" and evidence_type="anecdotal" for new entries.

func (*ObservationService) CaptureWithTrust

func (s *ObservationService) CaptureWithTrust(ctx context.Context, content, wisdomType, colonyName, sourceType, evidenceType string) (*ObservationResult, error)

CaptureWithTrust captures a new observation with specified source and evidence types.

type Pipeline

type Pipeline struct {
	Observe     *ObservationService
	Promote     *PromoteService
	Queen       *QueenService
	Consolidate *ConsolidationService
	// contains filtered or unexported fields
}

Pipeline wires all wisdom services together via event bus subscriptions. Observations flow through: capture -> trust scoring -> auto-promotion -> instinct creation -> QUEEN.md writing.

func NewPipeline

func NewPipeline(store *storage.Store, bus *events.Bus, config PipelineConfig) *Pipeline

NewPipeline creates a new pipeline with all services wired together.

func (*Pipeline) RunConsolidation

func (p *Pipeline) RunConsolidation(ctx context.Context) (*ConsolidationResult, error)

RunConsolidation runs the consolidation cycle and acts on the results: promotes eligible observations and queen-eligible instincts.

func (*Pipeline) Start

func (p *Pipeline) Start(ctx context.Context) error

Start subscribes to events and begins processing in background goroutines.

func (*Pipeline) Stop

func (p *Pipeline) Stop()

Stop unsubscribes from events and waits for goroutines to finish.

type PipelineConfig

type PipelineConfig struct {
	ColonyName string
	QueenPath  string // path to QUEEN.md relative to store
}

PipelineConfig holds configuration for the wisdom pipeline.

type PromoteService

type PromoteService struct {
	// contains filtered or unexported fields
}

PromoteService promotes observations to instincts with dedup and provenance.

func NewPromoteService

func NewPromoteService(store *storage.Store, bus *events.Bus) *PromoteService

NewPromoteService creates a new promotion service.

func (*PromoteService) Promote

func (s *PromoteService) Promote(ctx context.Context, obs colony.Observation, colonyName string) (*PromotionResult, error)

Promote promotes an observation to an instinct. Source: Shell instinct-store.sh lines 25-203

type PromotionResult

type PromotionResult struct {
	Instinct   colony.InstinctEntry
	IsNew      bool
	WasDeduped bool
}

PromotionResult holds the outcome of an instinct promotion.

type QueenPromotionResult

type QueenPromotionResult struct {
	EntryID      string
	Section      string
	QueenPath    string
	EntriesAdded int
	TotalEntries int
}

QueenPromotionResult holds the outcome of a QUEEN.md promotion.

type QueenService

type QueenService struct {
	// contains filtered or unexported fields
}

QueenService promotes instincts and patterns to QUEEN.md using the V2 template.

func NewQueenService

func NewQueenService(store *storage.Store, bus *events.Bus) *QueenService

NewQueenService creates a new queen promotion service.

func (*QueenService) PromoteBuildLearning

func (s *QueenService) PromoteBuildLearning(ctx context.Context, queenPath string, tag string, claim string, phaseID string, phaseName string, colonyName string) (*QueenPromotionResult, error)

PromoteBuildLearning writes a build learning entry to the Build Learnings section.

func (*QueenService) PromoteInstinct

func (s *QueenService) PromoteInstinct(ctx context.Context, queenPath string, instinct colony.InstinctEntry, colonyName string) (*QueenPromotionResult, error)

PromoteInstinct formats an instinct entry and writes it to the Instincts section.

func (*QueenService) PromotePattern

func (s *QueenService) PromotePattern(ctx context.Context, queenPath string, content string, colonyName string) (*QueenPromotionResult, error)

PromotePattern writes a pattern entry to the Codebase Patterns section.

func (*QueenService) PromotePreference

func (s *QueenService) PromotePreference(ctx context.Context, queenPath string, content string, colonyName string) (*QueenPromotionResult, error)

PromotePreference writes a preference entry to the User Preferences section.

func (*QueenService) WriteEntry

func (s *QueenService) WriteEntry(ctx context.Context, queenPath string, section string, entry string, colonyName string) (*QueenPromotionResult, error)

WriteEntry is the core write method that all other promotion methods delegate to. It validates the section, loads or creates the V2 template, checks for duplicates, replaces placeholders or appends entries, updates the Evolution Log and METADATA, and publishes a queen.write event.

type TrustInput

type TrustInput struct {
	SourceType string
	Evidence   string
	DaysSince  int
}

TrustInput holds the inputs for trust score calculation.

type TrustResult

type TrustResult struct {
	Score         float64
	SourceScore   float64
	EvidenceScore float64
	ActivityScore float64
	Tier          string
	TierIndex     int
}

TrustResult holds the output of trust score calculation.

func Calculate

func Calculate(input TrustInput) TrustResult

Calculate computes a trust score from the given input. Source: Shell trust-scoring.sh lines 37-134

type WisdomThresholdEntry

type WisdomThresholdEntry struct {
	Propose int
	Auto    int
}

WisdomThresholdEntry holds promotion thresholds for a wisdom type.

Jump to

Keyboard shortcuts

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