sqlite

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package sqlite persists QUANTUM_LOG data locally using a CGo-free driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAllocations

func ValidateAllocations(allocations []AllocationInput) error

Types

type Allocation

type Allocation struct {
	ProjectID   string `json:"project_id"`
	ProjectSlug string `json:"project_slug"`
	BasisPoints int64  `json:"basis_points"`
	Method      string `json:"method"`
	Confidence  string `json:"confidence"`
}

type AllocationInput

type AllocationInput struct {
	ProjectID   string
	BasisPoints int64
}

type ExportRecord

type ExportRecord struct {
	ID                     string       `json:"id"`
	OccurredAt             time.Time    `json:"occurred_at"`
	ProjectSlug            string       `json:"project_slug"`
	ProjectLocationPath    string       `json:"project_location_path,omitempty"`
	Provider               string       `json:"provider"`
	Model                  string       `json:"model"`
	Agent                  string       `json:"agent"`
	InputTokens            int64        `json:"input_tokens"`
	OutputTokens           int64        `json:"output_tokens"`
	ReasoningTokens        int64        `json:"reasoning_tokens"`
	CachedInputTokens      int64        `json:"cached_input_tokens"`
	CacheWriteTokens       int64        `json:"cache_write_tokens"`
	TotalTokens            int64        `json:"total_tokens"`
	EstimatedCostUSDMicros int64        `json:"estimated_cost_usd_micros"`
	CaptureQuality         string       `json:"capture_quality"`
	Allocations            []Allocation `json:"allocations"`
}

type ModelCallInput

type ModelCallInput struct {
	ProjectID              string
	ProjectLocationID      string
	WorkContextID          string
	TaskID                 string
	SessionID              string
	TurnID                 string
	Provider               string
	ModelID                string
	AgentName              string
	InputTokens            int64
	OutputTokens           int64
	ReasoningTokens        int64
	CachedInputTokens      int64
	CacheWriteTokens       int64
	EstimatedCostUSDMicros int64
	EstimatedCostEURMicros int64
	OccurredAt             time.Time
	CaptureQuality         string
}

type PricingRecalculateQuery

type PricingRecalculateQuery struct {
	From time.Time
	To   time.Time
}

type PricingRuleRecord

type PricingRuleRecord struct {
	ID        string       `json:"id"`
	Rule      pricing.Rule `json:"rule"`
	CreatedAt time.Time    `json:"created_at"`
}

type ProjectSummary

type ProjectSummary struct {
	ID            string    `json:"id"`
	Slug          string    `json:"slug"`
	Name          string    `json:"name"`
	LocationCount int64     `json:"location_count"`
	TagCount      int64     `json:"tag_count"`
	CreatedAt     time.Time `json:"created_at"`
}

type ProjectTag

type ProjectTag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type RawEventInput

type RawEventInput struct {
	Source               string
	SessionID            string
	EventType            string
	Payload              []byte
	OccurredAt           time.Time
	ProjectID            string
	ProjectLocationID    string
	WorkContextID        string
	ResolutionMethod     string
	ResolutionConfidence string
	EvidenceJSON         string
}

type Store

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

func Open

func Open(ctx context.Context, path string) (*Store, error)

func (*Store) AddPricingRule

func (s *Store) AddPricingRule(ctx context.Context, rule pricing.Rule) (PricingRuleRecord, error)

func (*Store) AddProjectTag

func (s *Store) AddProjectTag(ctx context.Context, projectID, key, value string) error

func (*Store) AppendRawEvent

func (s *Store) AppendRawEvent(ctx context.Context, input RawEventInput) (string, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateWorkContext

func (s *Store) CreateWorkContext(ctx context.Context, input WorkContextInput) (domain.WorkContext, error)

func (*Store) Doctor

func (s *Store) Doctor(ctx context.Context) error

func (*Store) EnsureSession

func (s *Store) EnsureSession(ctx context.Context, id, agentName string, startedAt time.Time) error

func (*Store) ExportModelCalls

func (s *Store) ExportModelCalls(ctx context.Context, query PricingRecalculateQuery) ([]ExportRecord, error)

func (*Store) FinishTask

func (s *Store) FinishTask(ctx context.Context, id, result string) error

func (*Store) ListPricingRules

func (s *Store) ListPricingRules(ctx context.Context) ([]PricingRuleRecord, error)

func (*Store) ListProjects

func (s *Store) ListProjects(ctx context.Context) ([]ProjectSummary, error)

func (*Store) ListTasks

func (s *Store) ListTasks(ctx context.Context, projectSlug string) ([]TaskRecord, error)

func (*Store) ModelCallAllocations

func (s *Store) ModelCallAllocations(ctx context.Context, modelCallID string) ([]Allocation, error)

func (*Store) ProjectBySlug

func (s *Store) ProjectBySlug(ctx context.Context, slug string) (domain.Project, domain.ProjectLocation, bool, error)

func (*Store) ProjectTags

func (s *Store) ProjectTags(ctx context.Context, projectID string) ([]ProjectTag, error)

func (*Store) RecalculateCosts

func (s *Store) RecalculateCosts(ctx context.Context, query PricingRecalculateQuery) (int, error)

func (*Store) RecordModelCall

func (s *Store) RecordModelCall(ctx context.Context, input ModelCallInput) (string, error)

func (*Store) RegisterProject

func (s *Store) RegisterProject(ctx context.Context, name, slug, path string) (domain.Project, domain.ProjectLocation, error)

func (*Store) RegisteredPaths

func (s *Store) RegisteredPaths(ctx context.Context) (map[string]string, error)

func (*Store) RepairModelCallAllocation

func (s *Store) RepairModelCallAllocation(ctx context.Context, modelCallID, projectID string) error

func (*Store) ReplaceAllocations

func (s *Store) ReplaceAllocations(ctx context.Context, subjectType, subjectID string, allocations []AllocationInput) error

func (*Store) StartTask

func (s *Store) StartTask(ctx context.Context, input TaskInput) (string, error)

func (*Store) Usage

func (s *Store) Usage(ctx context.Context, query UsageQuery) (UsageReport, error)

func (*Store) VerifyLedger

func (s *Store) VerifyLedger(ctx context.Context, sessionID string) error

type TaskInput

type TaskInput struct {
	ProjectID string
	Title     string
	TaskType  string
}

type TaskRecord

type TaskRecord struct {
	ID          string     `json:"id"`
	ProjectSlug string     `json:"project_slug"`
	Title       string     `json:"title"`
	TaskType    string     `json:"task_type"`
	Status      string     `json:"status"`
	Result      string     `json:"result"`
	StartedAt   time.Time  `json:"started_at"`
	FinishedAt  *time.Time `json:"finished_at,omitempty"`
}

type UsageQuery

type UsageQuery struct {
	From    time.Time
	To      time.Time
	GroupBy []string
}

type UsageReport

type UsageReport struct {
	GroupBy                []string   `json:"group_by"`
	Rows                   []UsageRow `json:"rows"`
	TotalTokens            int64      `json:"total_tokens"`
	AllocatedCostUSDMicros int64      `json:"allocated_cost_usd_micros"`
}

type UsageRow

type UsageRow struct {
	ProjectSlug            string `json:"project_slug"`
	Provider               string `json:"provider"`
	Model                  string `json:"model"`
	InputTokens            int64  `json:"input_tokens"`
	OutputTokens           int64  `json:"output_tokens"`
	TotalTokens            int64  `json:"total_tokens"`
	AllocatedCostUSDMicros int64  `json:"allocated_cost_usd_micros"`
}

type WorkContextInput

type WorkContextInput struct {
	ProjectID            string
	LocationID           string
	SessionID            string
	CWD                  string
	GitRoot              string
	GitBranch            string
	GitCommit            string
	StartedAt            time.Time
	ResolutionMethod     string
	ResolutionConfidence string
	EvidenceJSON         string
}

Jump to

Keyboard shortcuts

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