Documentation
¶
Overview ¶
Package store manages the DevSpecs SQLite database: opening, migrations, and queries.
Index ¶
- Constants
- type ArtifactRow
- type CriterionRow
- type DB
- func (db *DB) AssignArtifactShortID(artifactID, baseShort string) error
- func (db *DB) DeleteAutoTags(artifactID string) error
- func (db *DB) DeleteTag(artifactID, tag string) error
- func (db *DB) EnsureRepo(rootPath, now string) (string, error)
- func (db *DB) FindArtifacts(query string, fp FilterParams) ([]ArtifactRow, error)
- func (db *DB) FindSourceByIdentity(identity string) (string, error)
- func (db *DB) GetArtifact(idOrPrefix string) (*ArtifactRow, error)
- func (db *DB) GetCriteriaForArtifact(artifactID string) ([]CriterionRow, error)
- func (db *DB) GetLinksForArtifact(artifactID string) ([]LinkRow, error)
- func (db *DB) GetRepoByRoot(rootPath string) *RepoMeta
- func (db *DB) GetRevision(id string) (*RevisionRow, error)
- func (db *DB) GetSourcesForArtifact(artifactID string) ([]SourceRow, error)
- func (db *DB) GetTagsForArtifact(artifactID string) ([]TagRow, error)
- func (db *DB) GetTodosForArtifact(artifactID string) ([]TodoRow, error)
- func (db *DB) IndexArtifactFTS(artifactID, title, body, sourcePath string) error
- func (db *DB) InsertArtifactDirect(id, repoID, kind, subtype, title, status, revID, authoredAt, now string) error
- func (db *DB) InsertLink(id, artifactID, linkType, target, now string) error
- func (db *DB) InsertRevisionDirect(id, artifactID, contentHash, body, extractedJSON, now string) error
- func (db *DB) InsertSourceDirect(...) error
- func (db *DB) InsertTag(artifactID, tag, source, now string) error
- func (db *DB) ListAllCriteria(fp FilterParams, openOnly, doneOnly bool, criteriaKind string) ([]CriterionRow, error)
- func (db *DB) ListAllTodos(fp FilterParams, openOnly, doneOnly bool) ([]TodoRow, error)
- func (db *DB) ListArtifacts(fp FilterParams) ([]ArtifactRow, error)
- func (db *DB) ResumeArtifacts(repoRoot string, fp FilterParams) ([]ResumeRow, error)
- func (db *DB) UpdateArtifactShortID(artifactID, shortID string) error
- func (db *DB) UpdateArtifactStatus(artifactID, status, now string) error
- func (db *DB) UpdateScanMeta(repoID, commit, scannedBy, now string)
- type FilterParams
- type LinkRow
- type RepoMeta
- type ResumeRow
- type RevisionRow
- type SourceRow
- type TagRow
- type TodoRow
Constants ¶
const SchemaVersion = 7
SchemaVersion is the current schema version. Bump when schema.sql changes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArtifactRow ¶
type ArtifactRow struct {
ID string
RepoID string
ShortID string
Kind string
Subtype string
Title string
Status string
CurrentRevID string
CreatedAt string
UpdatedAt string
LastObservedAt string
}
ArtifactRow represents a row from the artifacts table.
type CriterionRow ¶
type CriterionRow struct {
ID string
ArtifactID string
RevisionID string
Ordinal int
Text string
Done bool
SourceFile string
SourceLine int
CriteriaKind string
}
CriterionRow represents a row from the artifact_criteria table.
type DB ¶
DB wraps *sql.DB with DevSpecs-specific operations.
func Open ¶
Open opens or creates the SQLite database at the given path. It ensures the parent directory exists and applies migrations.
func (*DB) AssignArtifactShortID ¶
AssignArtifactShortID sets short_id to baseShort, or baseShort with a numeric suffix, until UNIQUE succeeds.
func (*DB) DeleteAutoTags ¶
DeleteAutoTags removes all frontmatter and inferred tags for an artifact (preserving manual).
func (*DB) EnsureRepo ¶
EnsureRepo creates or returns the repo ID for the given root path.
func (*DB) FindArtifacts ¶
func (db *DB) FindArtifacts(query string, fp FilterParams) ([]ArtifactRow, error)
FindArtifacts does a text search across title, source path, and body. It tries FTS5 first, falling back to LIKE if FTS returns no results or errors.
func (*DB) FindSourceByIdentity ¶
FindSourceByIdentity checks if a source_identity already exists and returns the artifact ID.
func (*DB) GetArtifact ¶
func (db *DB) GetArtifact(idOrPrefix string) (*ArtifactRow, error)
GetArtifact retrieves a single artifact by full ID, short_id, or prefix.
func (*DB) GetCriteriaForArtifact ¶
func (db *DB) GetCriteriaForArtifact(artifactID string) ([]CriterionRow, error)
GetCriteriaForArtifact returns extracted criteria for a specific artifact.
func (*DB) GetLinksForArtifact ¶
GetLinksForArtifact returns all links for an artifact.
func (*DB) GetRepoByRoot ¶
GetRepoByRoot returns the repo row for a given root path, or nil if not found.
func (*DB) GetRevision ¶
func (db *DB) GetRevision(id string) (*RevisionRow, error)
GetRevision retrieves a revision by ID.
func (*DB) GetSourcesForArtifact ¶
GetSourcesForArtifact returns all sources for an artifact.
func (*DB) GetTagsForArtifact ¶
GetTagsForArtifact returns all tags for an artifact.
func (*DB) GetTodosForArtifact ¶
GetTodosForArtifact returns todos for a specific artifact.
func (*DB) IndexArtifactFTS ¶
IndexArtifactFTS inserts or updates the FTS5 index for an artifact.
func (*DB) InsertArtifactDirect ¶
func (db *DB) InsertArtifactDirect(id, repoID, kind, subtype, title, status, revID, authoredAt, now string) error
InsertArtifactDirect allows inserting an artifact directly (for capture).
func (*DB) InsertLink ¶
InsertLink adds a link for an artifact.
func (*DB) InsertRevisionDirect ¶
func (db *DB) InsertRevisionDirect(id, artifactID, contentHash, body, extractedJSON, now string) error
InsertRevisionDirect inserts a revision directly. extractedJSON may be empty for NULL.
func (*DB) InsertSourceDirect ¶
func (db *DB) InsertSourceDirect(id, artifactID, repoID, sourceType, path, sourceIdentity, formatProfile, layoutGroup, now string) error
InsertSourceDirect inserts a source directly.
func (*DB) ListAllCriteria ¶
func (db *DB) ListAllCriteria(fp FilterParams, openOnly, doneOnly bool, criteriaKind string) ([]CriterionRow, error)
ListAllCriteria returns criteria across all artifacts, optionally filtered. criteriaKind filters by criteria_kind when non-empty (acceptance, success, okr).
func (*DB) ListAllTodos ¶
func (db *DB) ListAllTodos(fp FilterParams, openOnly, doneOnly bool) ([]TodoRow, error)
ListAllTodos returns todos across all artifacts, optionally filtered.
func (*DB) ListArtifacts ¶
func (db *DB) ListArtifacts(fp FilterParams) ([]ArtifactRow, error)
ListArtifacts returns artifacts filtered by the given parameters.
func (*DB) ResumeArtifacts ¶
func (db *DB) ResumeArtifacts(repoRoot string, fp FilterParams) ([]ResumeRow, error)
ResumeArtifacts returns all artifacts for a repo, with todo counts, sorted by updated_at DESC.
func (*DB) UpdateArtifactShortID ¶
UpdateArtifactShortID sets the short_id for an artifact.
func (*DB) UpdateArtifactStatus ¶
UpdateArtifactStatus updates the status of an artifact.
func (*DB) UpdateScanMeta ¶
UpdateScanMeta records the git commit, timestamp, and user of the last scan.
type FilterParams ¶
type FilterParams struct {
RepoRoot string
Kind string
Subtype string
Status string
SourceType string
Tag string
Branch string
User string
}
FilterParams groups all query filters.
type RepoMeta ¶
type RepoMeta struct {
ID string
RootPath string
LastScanCommit string
LastScanAt string
ScannedBy string
}
RepoMeta holds freshness metadata for a repository.
type ResumeRow ¶
type ResumeRow struct {
ID string
ShortID string
Kind string
Subtype string
Title string
Status string
AuthoredAt string
UpdatedAt string
LastObservedAt string
SourcePath string
TotalTodos int
OpenTodos int
TagsJoined string // comma-separated from SQL GROUP_CONCAT
}
ResumeRow holds the data needed for ds resume display.
type RevisionRow ¶
type RevisionRow struct {
ID string
ArtifactID string
ContentHash string
Body string
ExtractedJSON string
ObservedAt string
}
RevisionRow represents a row from the artifact_revisions table.
type SourceRow ¶
type SourceRow struct {
ID string
ArtifactID string
SourceType string
Path string
SourceIdentity string
FormatProfile string
LayoutGroup string
}
SourceRow represents a row from the sources table.