Documentation
¶
Overview ¶
Package decay implements salience decay, reinforcement, and scheduling as specified in RFC 15A.7.
Index ¶
- func Exponential(currentSalience, elapsedSeconds float64, profile schema.DecayProfile) float64
- type DecayFunc
- type Scheduler
- type Service
- func (s *Service) ApplyDecay(ctx context.Context, id string) error
- func (s *Service) ApplyDecayAll(ctx context.Context) (int, error)
- func (s *Service) Penalize(ctx context.Context, id string, amount float64, actor string, rationale string) error
- func (s *Service) Prune(ctx context.Context) (int, error)
- func (s *Service) Reinforce(ctx context.Context, id string, actor string, rationale string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exponential ¶
func Exponential(currentSalience, elapsedSeconds float64, profile schema.DecayProfile) float64
Exponential computes exponential decay: salience * 2^(-elapsed/halfLife), floored at MinSalience. RFC 15A.7: Exponential decay with half-life parameter.
Types ¶
type DecayFunc ¶
type DecayFunc func(currentSalience float64, elapsedSeconds float64, profile schema.DecayProfile) float64
DecayFunc takes current salience, elapsed seconds since last reinforcement, and the decay profile, returns new salience.
func GetDecayFunc ¶
func GetDecayFunc(curve schema.DecayCurve) DecayFunc
GetDecayFunc returns the decay function used by the implementation. Membrane currently supports exponential decay only.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler runs periodic decay sweeps across all records.
func NewScheduler ¶
NewScheduler creates a new decay scheduler that runs ApplyDecayAll at the given interval.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service applies decay and reinforcement to memory records.
func NewService ¶
NewService creates a new decay service backed by the given store.
func (*Service) ApplyDecay ¶
ApplyDecay calculates and applies decay to a single record's salience based on elapsed time since LastReinforcedAt.
func (*Service) ApplyDecayAll ¶
ApplyDecayAll applies decay to all non-pinned records and returns the count of records processed.
func (*Service) Penalize ¶
func (s *Service) Penalize(ctx context.Context, id string, amount float64, actor string, rationale string) error
Penalize reduces a record's salience by the given amount, floored at MinSalience, and adds an audit entry.