selfreflect

package
v0.0.0-...-8acab51 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) ApproveProposal

func (h *Handler) ApproveProposal(c echo.Context) error

func (*Handler) GetPatchPreview

func (h *Handler) GetPatchPreview(c echo.Context) error

func (*Handler) GetProposal

func (h *Handler) GetProposal(c echo.Context) error

func (*Handler) ListProposals

func (h *Handler) ListProposals(c echo.Context) error

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(g *echo.Group)

func (*Handler) RejectProposal

func (h *Handler) RejectProposal(c echo.Context) error

type Input

type Input struct {
	TaskID             string                 `json:"task_id,omitempty"`
	Goal               string                 `json:"goal"`
	Plan               []Step                 `json:"plan,omitempty"`
	VerificationOutput string                 `json:"verification_output,omitempty"`
	FinalStatus        string                 `json:"final_status,omitempty"`
	ResultSummary      string                 `json:"result_summary,omitempty"`
	FailureReason      string                 `json:"failure_reason,omitempty"`
	OwnerUserID        string                 `json:"owner_user_id,omitempty"`
	SourceKind         string                 `json:"source_kind,omitempty"`
	SourceID           string                 `json:"source_id,omitempty"`
	TriggerKind        string                 `json:"trigger_kind,omitempty"`
	EvidenceWindow     []RuntimeEvidenceItem  `json:"evidence_window,omitempty"`
	RuntimeSignals     map[string]interface{} `json:"runtime_signals,omitempty"`
	DisableMemoryWrite bool                   `json:"disable_memory_write,omitempty"`
	EvaluationSummary  map[string]interface{} `json:"evaluation_summary,omitempty"`
	ProposalCandidates []ProposalCandidate    `json:"proposal_candidates,omitempty"`
	ProposalMode       ProposalMode           `json:"proposal_mode,omitempty"`
}

type LLMCaller

type LLMCaller interface {
	Chat(ctx context.Context, req llm.ChatRequest) (*llm.ChatResponse, error)
}

type Lesson

type Lesson struct {
	Kind        LessonKind `json:"kind"`
	Lesson      string     `json:"lesson"`
	WhenToApply string     `json:"when_to_apply"`
	Evidence    string     `json:"evidence"`
}

type LessonKind

type LessonKind string
const (
	LessonKindHeuristic   LessonKind = "heuristic"
	LessonKindAntiPattern LessonKind = "anti_pattern"
	LessonKindGuardrail   LessonKind = "guardrail"
)

type MemoryWriter

type MemoryWriter interface {
	Write(ctx context.Context, content string, tags []string) error
}

type MutationSuggestion

type MutationSuggestion struct {
	Kind          string   `json:"kind,omitempty"`
	TargetSkillID string   `json:"target_skill_id,omitempty"`
	Rationale     string   `json:"rationale,omitempty"`
	SuggestedText string   `json:"suggested_text,omitempty"`
	EvidenceIDs   []string `json:"evidence_ids,omitempty"`
	Signature     string   `json:"signature,omitempty"`
}

type Proposal

type Proposal struct {
	ID                 string                 `json:"id"`
	OwnerUserID        string                 `json:"owner_user_id,omitempty"`
	SourceKind         string                 `json:"source_kind,omitempty"`
	SourceID           string                 `json:"source_id,omitempty"`
	ProposalMode       ProposalMode           `json:"proposal_mode,omitempty"`
	TargetFile         string                 `json:"target_file"`
	TargetSection      string                 `json:"target_section,omitempty"`
	Status             ProposalStatus         `json:"status"`
	DedupKey           string                 `json:"dedup_key,omitempty"`
	Lesson             string                 `json:"lesson"`
	WhenToApply        string                 `json:"when_to_apply,omitempty"`
	Evidence           string                 `json:"evidence"`
	EvidenceIDs        []string               `json:"evidence_ids,omitempty"`
	EvaluationSummary  map[string]interface{} `json:"evaluation_summary,omitempty"`
	CalibrationSummary map[string]interface{} `json:"calibration_summary,omitempty"`
	PatchPreview       string                 `json:"patch_preview,omitempty"`
	ReviewNote         string                 `json:"review_note,omitempty"`
	CreatedAt          time.Time              `json:"created_at"`
	UpdatedAt          time.Time              `json:"updated_at"`
	ReviewedAt         *time.Time             `json:"reviewed_at,omitempty"`
}

type ProposalCandidate

type ProposalCandidate struct {
	Lesson      string   `json:"lesson"`
	WhenToApply string   `json:"when_to_apply,omitempty"`
	Evidence    string   `json:"evidence"`
	EvidenceIDs []string `json:"evidence_ids,omitempty"`
	Confidence  float64  `json:"confidence,omitempty"`
	TargetFile  string   `json:"target_file,omitempty"`
}

type ProposalFilter

type ProposalFilter struct {
	OwnerUserID string
	SourceKind  string
	SourceID    string
	Statuses    []ProposalStatus
	Limit       int
}

type ProposalMode

type ProposalMode string
const (
	ProposalModeReviewOnly ProposalMode = "review_only"
)

type ProposalStatus

type ProposalStatus string
const (
	ProposalStatusPending  ProposalStatus = "pending"
	ProposalStatusApproved ProposalStatus = "approved"
	ProposalStatusRejected ProposalStatus = "rejected"
)

type ProposalStore

type ProposalStore interface {
	CreateProposal(ctx context.Context, proposal *Proposal) error
	UpdateProposal(ctx context.Context, proposal *Proposal) error
	GetProposal(ctx context.Context, id string) (*Proposal, error)
	ListProposals(ctx context.Context, filter ProposalFilter) ([]Proposal, error)
	FindProposalByDedup(ctx context.Context, dedupKey string, targetFile string) (*Proposal, error)
}

type Result

type Result struct {
	Summary               string               `json:"summary"`
	Lessons               []Lesson             `json:"lessons,omitempty"`
	MutationSuggestions   []MutationSuggestion `json:"mutation_suggestions,omitempty"`
	ReflectionSignature   string               `json:"reflection_signature,omitempty"`
	SignalStrength        string               `json:"signal_strength,omitempty"`
	MemoryWritten         int                  `json:"memory_written"`
	SkippedReason         string               `json:"skipped_reason,omitempty"`
	ProposalCount         int                  `json:"proposal_count,omitempty"`
	ProposalIDs           []string             `json:"proposal_ids,omitempty"`
	ProposalSkippedReason string               `json:"proposal_skipped_reason,omitempty"`
}

type RuntimeEvidenceItem

type RuntimeEvidenceItem struct {
	ID           string `json:"id,omitempty"`
	EventType    string `json:"event_type,omitempty"`
	StepIndex    int    `json:"step_index,omitempty"`
	PlannerRound int    `json:"planner_round,omitempty"`
	Summary      string `json:"summary,omitempty"`
	PayloadJSON  string `json:"payload_json,omitempty"`
}

type SQLiteProposalStore

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

func NewSQLiteProposalStore

func NewSQLiteProposalStore(db *sql.DB) (*SQLiteProposalStore, error)

func NewSQLiteProposalStoreWithReadDB

func NewSQLiteProposalStoreWithReadDB(writeDB, readDB *sql.DB) (*SQLiteProposalStore, error)

NewSQLiteProposalStoreWithReadDB creates a proposal store with separate write and read database handles.

func (*SQLiteProposalStore) CreateProposal

func (s *SQLiteProposalStore) CreateProposal(ctx context.Context, proposal *Proposal) error

func (*SQLiteProposalStore) FindProposalByDedup

func (s *SQLiteProposalStore) FindProposalByDedup(ctx context.Context, dedupKey string, targetFile string) (*Proposal, error)

func (*SQLiteProposalStore) GetProposal

func (s *SQLiteProposalStore) GetProposal(ctx context.Context, id string) (*Proposal, error)

func (*SQLiteProposalStore) ListProposals

func (s *SQLiteProposalStore) ListProposals(ctx context.Context, filter ProposalFilter) ([]Proposal, error)

func (*SQLiteProposalStore) UpdateProposal

func (s *SQLiteProposalStore) UpdateProposal(ctx context.Context, proposal *Proposal) error

type Service

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

func NewService

func NewService(llmCaller LLMCaller, writer MemoryWriter) *Service

func (*Service) GetProposal

func (s *Service) GetProposal(ctx context.Context, id string) (*Proposal, error)

func (*Service) ListProposals

func (s *Service) ListProposals(ctx context.Context, filter ProposalFilter) ([]Proposal, error)

func (*Service) Reflect

func (s *Service) Reflect(ctx context.Context, input Input) (*Result, error)

func (*Service) ReviewProposal

func (s *Service) ReviewProposal(ctx context.Context, id string, status ProposalStatus, reviewNote string) (*Proposal, error)

func (*Service) SetLLMCaller

func (s *Service) SetLLMCaller(llmCaller LLMCaller)

func (*Service) SetMemoryWriter

func (s *Service) SetMemoryWriter(writer MemoryWriter)

func (*Service) SetProposalGateFunc

func (s *Service) SetProposalGateFunc(fn func() bool)

func (*Service) SetProposalStore

func (s *Service) SetProposalStore(store ProposalStore)

func (*Service) SetWorkspaceManager

func (s *Service) SetWorkspaceManager(mgr *workspace.Manager)

type Step

type Step struct {
	Description string `json:"description"`
	Status      string `json:"status,omitempty"`
	Output      string `json:"output,omitempty"`
}

Jump to

Keyboard shortcuts

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