Documentation
¶
Overview ¶
Package memory implements the wisdom pipeline including trust scoring, observation capture, instinct promotion, and memory consolidation.
Index ¶
- Variables
- func CheckPromotion(obs colony.Observation) (bool, string)
- func Decay(score float64, days int) float64
- func RecurrenceConfidence(observationCount int) float64
- func Tier(score float64) (string, int)
- type ConsolidationResult
- type ConsolidationService
- type ObservationResult
- type ObservationService
- type Pipeline
- type PipelineConfig
- type PromoteService
- type PromotionResult
- type QueenPromotionResult
- type QueenService
- func (s *QueenService) PromoteBuildLearning(ctx context.Context, queenPath string, tag string, claim string, ...) (*QueenPromotionResult, error)
- func (s *QueenService) PromoteInstinct(ctx context.Context, queenPath string, instinct colony.InstinctEntry, ...) (*QueenPromotionResult, error)
- func (s *QueenService) PromotePattern(ctx context.Context, queenPath string, content string, colonyName string) (*QueenPromotionResult, error)
- func (s *QueenService) PromotePreference(ctx context.Context, queenPath string, content string, colonyName string) (*QueenPromotionResult, error)
- func (s *QueenService) WriteEntry(ctx context.Context, queenPath string, section string, entry string, ...) (*QueenPromotionResult, error)
- type TrustInput
- type TrustResult
- type WisdomThresholdEntry
Constants ¶
This section is empty.
Variables ¶
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 ¶
Decay applies half-life decay to an existing trust score. Source: trust-scoring.sh decay logic
func RecurrenceConfidence ¶
RecurrenceConfidence calculates the confidence based on observation count. Source: learning.sh lines 469-475 Formula: min(0.7 + (observationCount - 1) * 0.05, 0.9)
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 ¶
func (s *ConsolidationService) Run(ctx context.Context) (*ConsolidationResult, error)
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 ¶
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.
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 ¶
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 ¶
WisdomThresholdEntry holds promotion thresholds for a wisdom type.