Documentation
¶
Index ¶
- type CachedIssue
- type DB
- func (db *DB) BeginTx() error
- func (db *DB) CacheIssues(repo string, issues []CachedIssue) error
- func (db *DB) ClaimTask(id, agentID string) error
- func (db *DB) ClearIssueCache() error
- func (db *DB) Close() error
- func (db *DB) CommitTx() error
- func (db *DB) CreateTask(title, description, repo string) (string, error)
- func (db *DB) DeleteByFile(repo, file string) error
- func (db *DB) GetAllEmbeddings() ([]EmbeddingRecord, error)
- func (db *DB) GetCacheAge(repos []string) time.Duration
- func (db *DB) GetCachedIssues(repo string) ([]CachedIssue, error)
- func (db *DB) GetIndexState(filePath string) (IndexState, error)
- func (db *DB) GetTask(id string) (*Task, error)
- func (db *DB) ListTasks(status, agentID, repo string) ([]Task, error)
- func (db *DB) Path() string
- func (db *DB) RollbackTx() error
- func (db *DB) SetIndexState(filePath, checksum string, mtimeNs, fileSize int64) error
- func (db *DB) StoreEmbedding(repo, file string, chunkIndex, lineStart, lineEnd int, contentHash string, ...) error
- func (db *DB) UpdateTaskStatus(id, status string) error
- type EmbeddingRecord
- type IndexState
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedIssue ¶
type CachedIssue struct {
ID string `json:"id"`
Repo string `json:"repo"`
Source string `json:"source"` // "github" or "gitlab"
Title string `json:"title"`
Body string `json:"body,omitempty"`
Status string `json:"status"`
URL string `json:"url,omitempty"`
Author string `json:"author,omitempty"`
Labels string `json:"labels,omitempty"`
CreatedAt time.Time `json:"created_at"`
FetchedAt time.Time `json:"fetched_at"`
}
CachedIssue represents a cached remote issue.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a SQLite-backed state store for tasks, embeddings, and index state.
func Open ¶
Open opens or creates the state database at .mit/state.db under the workspace root found by walking up from dir.
func (*DB) CacheIssues ¶
func (db *DB) CacheIssues(repo string, issues []CachedIssue) error
CacheIssues replaces the cached issues for a given repo with fresh data.
func (*DB) ClaimTask ¶
ClaimTask atomically assigns a task to an agent. It only succeeds when the task has status "open" and agent_id IS NULL. Returns an error if the task was already claimed or does not exist.
func (*DB) ClearIssueCache ¶
ClearIssueCache removes all cached issues.
func (*DB) CreateTask ¶
CreateTask inserts a new task with status "open" and returns its UUID.
func (*DB) DeleteByFile ¶
DeleteByFile removes all embedding records for a given repo and file.
func (*DB) GetAllEmbeddings ¶
func (db *DB) GetAllEmbeddings() ([]EmbeddingRecord, error)
GetAllEmbeddings returns every embedding record.
func (*DB) GetCacheAge ¶
GetCacheAge returns the age of the oldest cached entry for the given repos. Returns 0 if cache is empty. If repos is empty, checks all cached repos.
func (*DB) GetCachedIssues ¶
func (db *DB) GetCachedIssues(repo string) ([]CachedIssue, error)
GetCachedIssues returns cached issues, optionally filtered by repo.
func (*DB) GetIndexState ¶
func (db *DB) GetIndexState(filePath string) (IndexState, error)
GetIndexState returns the stored state for a file path. If the file has not been indexed, it returns a zero IndexState and a nil error.
func (*DB) ListTasks ¶
ListTasks returns tasks matching the optional filters. Pass empty strings to skip a filter.
func (*DB) RollbackTx ¶
RollbackTx rolls back the active transaction.
func (*DB) SetIndexState ¶
SetIndexState upserts the state for a file path.
func (*DB) StoreEmbedding ¶
func (db *DB) StoreEmbedding(repo, file string, chunkIndex, lineStart, lineEnd int, contentHash string, embedding []byte) error
StoreEmbedding inserts a new embedding record.
func (*DB) UpdateTaskStatus ¶
UpdateTaskStatus changes the status of a task. If the new status is "completed", the completed_at timestamp is set.
type EmbeddingRecord ¶
type EmbeddingRecord struct {
ID int64 `json:"id"`
Repo string `json:"repo"`
File string `json:"file"`
ChunkIndex int `json:"chunk_index"`
LineStart int `json:"line_start"`
LineEnd int `json:"line_end"`
ContentHash string `json:"content_hash"`
Embedding []byte `json:"embedding"`
}
EmbeddingRecord represents a row in the embeddings table.
type IndexState ¶
IndexState holds the stored state for a file in the index.
type Task ¶
type Task struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
AgentID string `json:"agent_id,omitempty"`
ParentID string `json:"parent_id,omitempty"`
Repo string `json:"repo,omitempty"`
CreatedAt time.Time `json:"created_at"`
ClaimedAt *time.Time `json:"claimed_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Metadata string `json:"metadata,omitempty"`
}
Task represents a row in the tasks table.