Documentation
¶
Overview ¶
Package reflect is Stella's self-improvement loop: it reviews finished conversations on a scheduler builtin, gates candidates, reconciles the skills it owns, and curates skill usage. Everything it writes is attributed to reflect so a human can tell it apart from an authored change.
Index ¶
- Constants
- func NewBuiltinHandler(cfg Config) (scheduler.OnJobFunc, error)
- type CandidateGateConfig
- type CandidateGateDecision
- type CandidateGateInput
- type CandidateGateResult
- type CandidateGateSettings
- type CandidateRef
- type Config
- type RejectReason
- type ReviewSkip
- type ReviewSkipReason
- type ReviewUnit
- type Service
- type Store
- type UsageCuratorMode
- type UsageCuratorSettings
- type UsageCuratorStore
Constants ¶
const BuiltinJobName = "reflect-review"
BuiltinJobName is the scheduler builtin name reflect registers under. Exported so gateway wiring and operational tooling refer to one source.
Variables ¶
This section is empty.
Functions ¶
func NewBuiltinHandler ¶ added in v0.38.0
NewBuiltinHandler returns a scheduler.OnJobFunc that runs one reflect review cycle per fire. Cycle-level failures (store errors, ctx cancellation) surface as errors so the scheduler marks the run errored. Per-agent failures are still logged inside the service and do not fail the run.
Types ¶
type CandidateGateConfig ¶ added in v0.60.0
type CandidateGateDecision ¶ added in v0.60.0
type CandidateGateDecision struct {
Ref CandidateRef
NormalizedOverall float64
Scores map[string]int
Reason RejectReason
}
type CandidateGateInput ¶ added in v0.60.0
type CandidateGateInput struct {
Ref CandidateRef
Content string
Scores map[string]int
}
type CandidateGateResult ¶ added in v0.60.0
type CandidateGateResult struct {
Accepted []CandidateGateDecision
Rejected []CandidateGateDecision
}
type CandidateGateSettings ¶ added in v0.60.0
type CandidateGateSettings struct {
FactWeights map[string]float64
FactThreshold float64
FactSubjectCap int
SkillWeights map[string]float64
SkillThreshold float64
SkillCandidateCap int
}
CandidateGateSettings keeps #532 score gates configurable without exposing a persistent confidence field or coupling thresholds to prompt text.
type CandidateRef ¶ added in v0.60.0
type CandidateRef string
CandidateRef is a stable in-review identifier assigned after generation. It is intentionally sequential in #532; hash-based refs are deferred.
type Config ¶
type Config struct {
StateStore pkgplugins.StateStore
Memory memory.Provider
Store Store
// Snapshots loads credential-aware per-agent snapshots for review.
Snapshots config.SnapshotLoader
SkillStore reflectSkillStore
// SkillAuthorizer applies Skill domain rules to Reflect's staged writes.
SkillAuthorizer skillWriteAuthorizer
UsageCuratorStore UsageCuratorStore
Log *slog.Logger
Providers func(api, apiKey, baseURL string) (providers.StreamFunc, error)
CandidateGates CandidateGateSettings
// UsageCuratorSettings defaults to armed. Operators may switch to shadow to
// stop lifecycle writes while keeping scans and telemetry active.
UsageCuratorSettings UsageCuratorSettings
// Services provides the per-agent session registry used for review target
// listing and owner-scoped memory coordinates.
Services agent.ServiceManager
}
Config holds dependencies for the reflect service.
type RejectReason ¶ added in v0.60.0
type RejectReason string
type ReviewSkip ¶ added in v0.60.0
type ReviewSkipReason ¶ added in v0.60.0
type ReviewSkipReason string
type ReviewUnit ¶ added in v0.60.0
type ReviewUnit struct {
Text string
ReviewFromAt time.Time
ReviewFromSeq int64
LastIncludedAt time.Time
LastIncludedSeq int64
// Truncated means more fresh content exists after LastIncluded*, but it did
// not fit in this bounded window and must be picked up by a later cycle.
Truncated bool
Skipped []ReviewSkip
FreshCount int
PrivateOneToOne bool
SkillUsage []reviewSkillUsage
}
ReviewUnit is the bounded, fresh conversation window consumed by candidate generators. It keeps the watermark boundary explicit so each reflect line can advance independently after a successful review.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs background conversation review.
func (*Service) ReviewConversationReconciledCandidates ¶ added in v0.60.0
func (s *Service) ReviewConversationReconciledCandidates(ctx context.Context, snap *config.Snapshot, target reviewTarget) (candidatePipelineResult, error)
ReviewConversationReconciledCandidates runs structured candidate generation, evaluation, reconciliation, and writes. A line advances only after all work for that line completes.
func (*Service) RunOnce ¶
RunOnce executes the scheduler-owned review cycle across all enabled agents. Production and immediate operator runs must go through the registered scheduler builtin (using scheduler.RunJobNow for the latter) so concurrency control and run records are preserved. It returns the first cycle-level error; per-agent failures are logged inside runCycle and do not surface here.
type Store ¶ added in v0.38.0
Store lists the Agents Reflect reviews. Snapshot loading is a separate, credential-aware dependency.
type UsageCuratorMode ¶ added in v0.60.0
type UsageCuratorMode string
const ( UsageCuratorModeShadow UsageCuratorMode = "shadow" UsageCuratorModeArmed UsageCuratorMode = "armed" )
type UsageCuratorSettings ¶ added in v0.60.0
type UsageCuratorStore ¶ added in v0.60.0
type UsageCuratorStore interface {
ListReflectUsagePairs(ctx context.Context) ([]usageCuratorPair, error)
ListStaleReflectKnowledge(ctx context.Context, q usageCuratorKnowledgeQuery) ([]usageCuratorKnowledgeCandidate, error)
ListStaleReflectSkills(ctx context.Context, q usageCuratorSkillQuery) ([]usageCuratorSkillCandidate, error)
}
func NewSQLUsageCuratorStore ¶ added in v0.60.0
func NewSQLUsageCuratorStore(q *sqlc.Queries) UsageCuratorStore
func NewSQLUsageCuratorStoreForPool ¶ added in v0.60.0
func NewSQLUsageCuratorStoreForPool(pool *pgxpool.Pool) UsageCuratorStore
NewSQLUsageCuratorStoreForPool builds a UsageCuratorStore backed by the given connection pool, owning construction of its sqlc query set.
Source Files
¶
- candidate_gate_settings.go
- candidate_pipeline.go
- candidate_runner.go
- candidate_tools.go
- candidate_types.go
- capture.go
- conversation_review.go
- dispatcher.go
- doc.go
- fact_candidates.go
- fact_reconciliation.go
- fact_reconciliation_execute.go
- gates.go
- loop.go
- prompts.go
- provenance.go
- reconciliation_capture.go
- reconciliation_pipeline.go
- reconciliation_runner.go
- reconciliation_service.go
- related_bundle.go
- related_discovery.go
- review_agent_cursor.go
- review_targets.go
- review_unit.go
- service.go
- skill_candidates.go
- skill_reconciliation.go
- skill_reconciliation_execute.go
- store.go
- trace.go
- usage_curator.go
- usage_curator_service.go
- usage_curator_sql.go
- watermark.go