db

package
v0.0.0-...-6b72c33 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyJournalRecord

type ApplyJournalRecord struct {
	ID                int64
	ProposalID        int64
	ActionID          string
	NotePath          string
	ActionKind        string
	PlannedChangeJSON string
	Status            string
	CreatedAt         string
	CompletedAt       string
	Error             string
}

type ChangeRecord

type ChangeRecord struct {
	ID                 int64
	ProposalID         int64
	ActionID           string
	NotePath           string
	ActionKind         string
	BeforeHash         string
	AfterHash          string
	PreviousContent    string
	AppliedContent     string
	ForwardPatch       string
	InversePatch       string
	AffectedRangesJSON string
	AnchorsJSON        string
	AppliedAt          string
}

type ChunkRow

type ChunkRow struct {
	ID             int64
	NoteID         int64
	NotePath       string
	Title          string
	ChunkIndex     int
	Content        string
	ContentHash    string
	HeadingContext string
	TokenEstimate  int
}

type ConflictRecord

type ConflictRecord struct {
	ID           int64
	ProposalID   int64
	ChangeID     int64
	NotePath     string
	Reason       string
	ConflictJSON string
	CreatedAt    string
}

type DB

type DB struct {
	SQL             *sql.DB
	Path            string
	VectorAvailable bool
	// contains filtered or unexported fields
}

func Open

func Open(ctx context.Context, path string, logger *log.Logger) (*DB, error)

func (*DB) BackfillVectorIndex

func (d *DB) BackfillVectorIndex(ctx context.Context) (int, error)

func (*DB) ChunksNeedingEmbeddings

func (d *DB) ChunksNeedingEmbeddings(ctx context.Context, vaultID int64, model string, limit int) ([]ChunkRow, error)

func (*DB) Close

func (d *DB) Close() error

func (*DB) CompleteApplyJournal

func (d *DB) CompleteApplyJournal(ctx context.Context, id int64, status string, errorText string) error

func (*DB) GetProposal

func (d *DB) GetProposal(ctx context.Context, id int64) (ProposalRecord, error)

func (*DB) IndexScan

func (d *DB) IndexScan(ctx context.Context, vaultID int64, result vault.ScanResult, chunkSize, overlap int, force bool) (ScanStats, error)

func (*DB) ListApplyJournal

func (d *DB) ListApplyJournal(ctx context.Context, proposalID int64) ([]ApplyJournalRecord, error)

func (*DB) ListChanges

func (d *DB) ListChanges(ctx context.Context, proposalID int64) ([]ChangeRecord, error)

func (*DB) ListChunks

func (d *DB) ListChunks(ctx context.Context, vaultID int64) ([]ChunkRow, error)

func (*DB) ListEmbeddings

func (d *DB) ListEmbeddings(ctx context.Context, vaultID int64, model string) ([]ChunkRow, [][]float64, error)

func (*DB) ListNotes

func (d *DB) ListNotes(ctx context.Context, vaultID int64) ([]NoteRow, error)

func (*DB) ListProposals

func (d *DB) ListProposals(ctx context.Context, vaultID int64, status string, all bool) ([]ProposalRecord, error)

func (*DB) Migrate

func (d *DB) Migrate(ctx context.Context) error

func (*DB) NoteByPath

func (d *DB) NoteByPath(ctx context.Context, vaultID int64, path string) (NoteRow, error)

func (*DB) SaveApplyJournal

func (d *DB) SaveApplyJournal(ctx context.Context, c ChangeRecord, plannedJSON string) (int64, error)

func (*DB) SaveChange

func (d *DB) SaveChange(ctx context.Context, c ChangeRecord) (int64, error)

func (*DB) SaveConflict

func (d *DB) SaveConflict(ctx context.Context, c ConflictRecord) (int64, error)

func (*DB) SaveProposal

func (d *DB) SaveProposal(ctx context.Context, vaultID int64, typ, title, summary, proposalJSON, patchText string) (int64, error)

func (*DB) SearchChunks

func (d *DB) SearchChunks(ctx context.Context, vaultID int64, query string, limit int) ([]ChunkRow, error)

func (*DB) SearchVecChunks

func (d *DB) SearchVecChunks(ctx context.Context, vaultID int64, model string, queryJSON string, limit int) ([]VectorSearchRow, error)

func (*DB) Status

func (d *DB) Status(ctx context.Context, vaultPath string) (Status, error)

func (*DB) StoreEmbedding

func (d *DB) StoreEmbedding(ctx context.Context, chunk ChunkRow, model string, vector []float64) error

func (*DB) Tx

func (d *DB) Tx(ctx context.Context, fn func(*sql.Tx) error) error

func (*DB) UpdateProposalStatus

func (d *DB) UpdateProposalStatus(ctx context.Context, id int64, status string) error

func (*DB) UpsertVault

func (d *DB) UpsertVault(ctx context.Context, name, path string, cliEnabled, uriEnabled bool) (int64, error)

func (*DB) VaultID

func (d *DB) VaultID(ctx context.Context, vaultPath string) (int64, error)

type NoteRow

type NoteRow struct {
	ID          int64
	Path        string
	Title       string
	AliasesJSON string
	ContentHash string
	WordCount   int
	ModifiedAt  string
	IndexedAt   string
}

type ProposalRecord

type ProposalRecord struct {
	ID           int64
	VaultID      int64
	Type         string
	Title        string
	Summary      string
	Status       string
	ProposalJSON string
	PatchText    string
	CreatedAt    string
	AppliedAt    string
	RejectedAt   string
	RolledBackAt string
}

type ScanStats

type ScanStats struct {
	NotesIndexed     int `json:"notes_indexed"`
	NotesSkipped     int `json:"notes_skipped"`
	ChunksIndexed    int `json:"chunks_indexed"`
	EmbeddingsStored int `json:"embeddings_stored"`
	TotalEmbeddings  int `json:"total_embeddings"`
	VectorIndexed    int `json:"vector_indexed"`
}

type Status

type Status struct {
	VaultID          int64  `json:"vault_id"`
	VaultName        string `json:"vault_name"`
	VaultPath        string `json:"vault_path"`
	Notes            int    `json:"notes"`
	LastScan         string `json:"last_scan"`
	DatabasePath     string `json:"database_path"`
	VectorAvailable  bool   `json:"vector_available"`
	EmbeddingsStored int    `json:"embeddings_stored"`
	VectorIndexed    int    `json:"vector_indexed"`
	PendingProposals int    `json:"pending_proposals"`
	AppliedProposals int    `json:"applied_proposals"`
}

type VectorSearchRow

type VectorSearchRow struct {
	Chunk ChunkRow
	Score float64
}

Jump to

Keyboard shortcuts

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