memory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeFact     = "fact"
	TypeDecision = "decision"
	TypeEvent    = "event"
	TypeTask     = "task"

	StatusDraft      = "draft"
	StatusConfirmed  = "confirmed"
	StatusSuperseded = "superseded"
	StatusExpired    = "expired"
	StatusRejected   = "rejected"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Record  Record
	FTSRank int
}

type CaptureRequest

type CaptureRequest struct {
	Type       string
	Subject    string
	Predicate  string
	Object     string
	Body       string
	Status     string
	Confidence string
	SourceURI  string
	SourceSpan string
	Entities   []string
	DryRun     bool
}

type Entity

type Entity struct {
	ID           string    `gorm:"primaryKey" json:"id"`
	Kind         string    `gorm:"index" json:"kind"`
	Name         string    `json:"name"`
	CanonicalKey string    `gorm:"uniqueIndex" json:"canonical_key"`
	CreatedAt    time.Time `json:"created_at"`
}

func (Entity) TableName

func (Entity) TableName() string

type ListFilter

type ListFilter struct {
	Type              string
	Entity            string
	IncludeDraft      bool
	IncludeSuperseded bool
	IncludeExpired    bool
	IncludeRejected   bool
	Limit             int
}

type RecallFilter

type RecallFilter struct {
	Query  string
	Entity string
	Type   string
	Limit  int
}

type RecallHit

type RecallHit struct {
	Record       Record          `json:"record"`
	RecallReason string          `json:"recall_reason"`
	Score        int             `json:"score"`
	Signals      SignalBreakdown `json:"signals,omitempty"`
}

type Record

type Record struct {
	ID           string     `gorm:"primaryKey" json:"id"`
	Type         string     `gorm:"index" json:"type"`
	Subject      string     `gorm:"index" json:"subject,omitempty"`
	Predicate    string     `gorm:"index" json:"predicate,omitempty"`
	Object       string     `json:"object,omitempty"`
	Body         string     `json:"body,omitempty"`
	Status       string     `gorm:"index" json:"status"`
	Confidence   string     `gorm:"index" json:"confidence,omitempty"`
	SourceURI    string     `json:"source_uri,omitempty"`
	SourceSpan   string     `json:"source_span,omitempty"`
	SupersedesID string     `json:"supersedes_id,omitempty"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"updated_at"`
	ExpiresAt    *time.Time `json:"expires_at,omitempty"`
}

func BuildRecord

func BuildRecord(req CaptureRequest) (Record, error)

func (Record) TableName

func (Record) TableName() string

type RecordEntity

type RecordEntity struct {
	RecordID  string    `gorm:"primaryKey" json:"record_id"`
	EntityID  string    `gorm:"primaryKey" json:"entity_id"`
	CreatedAt time.Time `json:"created_at"`
}

func (RecordEntity) TableName

func (RecordEntity) TableName() string

type ScoredCandidate

type ScoredCandidate struct {
	Record       Record
	RecallReason string
	Score        int
	Signals      SignalBreakdown
}

type Scorer

type Scorer struct {
	Now time.Time
}

func (Scorer) Score

func (s Scorer) Score(filter RecallFilter, candidates []Candidate, ftsRank map[string]int, limit int) []RecallHit

type SignalBreakdown

type SignalBreakdown struct {
	KeywordFTS      bool   `json:"keyword_fts,omitempty"`
	KeywordField    string `json:"keyword_field,omitempty"`
	SourceKind      string `json:"source_kind,omitempty"`
	SourceAuthority int    `json:"source_authority,omitempty"`
	Confidence      int    `json:"confidence,omitempty"`
	Freshness       int    `json:"freshness,omitempty"`
	TaskFitness     int    `json:"task_fitness,omitempty"`
}

type Source

type Source struct {
	ID        string    `gorm:"primaryKey" json:"id"`
	RecordID  string    `gorm:"index" json:"record_id"`
	URI       string    `json:"uri"`
	Kind      string    `json:"kind"`
	Span      string    `json:"span,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

func (Source) TableName

func (Source) TableName() string

type Stats

type Stats struct {
	Records   int64 `json:"records"`
	Confirmed int64 `json:"confirmed"`
	Drafts    int64 `json:"drafts"`
}

type Store

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

func Open

func Open(root string) (*Store, error)

func (*Store) Capture

func (s *Store) Capture(ctx context.Context, req CaptureRequest) (Record, error)

func (*Store) List

func (s *Store) List(ctx context.Context, filter ListFilter) ([]Record, error)

func (*Store) Recall

func (s *Store) Recall(ctx context.Context, filter RecallFilter) ([]RecallHit, error)

func (*Store) Stats

func (s *Store) Stats(ctx context.Context) (Stats, error)

Jump to

Keyboard shortcuts

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