Documentation
¶
Overview ¶
Package sqlite implements the storage.Storage interface using SQLite. This file provides AI session and agent CRUD operations backed by the ai_sessions and ai_agents tables.
Package sqlite implements the storage interface using SQLite. This file provides database backup functionality for the CLI.
Package sqlite implements the storage interface using SQLite. This file handles comment and event operations.
Package sqlite implements the storage interface using SQLite. This file handles dependency (relationship) operations between issues.
Package sqlite implements the storage interface using SQLite. This file handles label operations including label definitions and issue-label associations.
Package sqlite implements the storage interface using SQLite. This file handles database schema migrations using goose.
Plans implements the storage layer for plan CRUD operations and plan comment management.
Package sqlite implements the storage interface using SQLite. This file handles ready work queries, blocked issue detection, and project statistics.
Package sqlite implements the storage interface using SQLite.
Package sqlite implements the storage.Storage interface using SQLite. This file contains workspace (directory path registration) operations.
Index ¶
- func IsHierarchicalID(id string) (isHierarchical bool, parentID string)
- func MigrationVersion(db *sql.DB) (int64, error)
- func PrepareSearchQuery(input string) string
- func RunMigrations(db *sql.DB) error
- type BackupResult
- type Store
- func (s *Store) AddComment(ctx context.Context, issueID, author, text string) (*types.Comment, error)
- func (s *Store) AddDependency(ctx context.Context, dep *types.Dependency, actor string) error
- func (s *Store) AddLabelToIssue(ctx context.Context, issueID, label, actor string) error
- func (s *Store) Close() error
- func (s *Store) CloseIssue(ctx context.Context, id string, reason string, cascade bool, actor string) error
- func (s *Store) CreateAIAgent(ctx context.Context, agent *types.AIAgent) error
- func (s *Store) CreateAISession(ctx context.Context, session *types.AISession) error
- func (s *Store) CreateIssue(ctx context.Context, issue *types.Issue, actor string) error
- func (s *Store) CreateLabel(ctx context.Context, label *types.Label) error
- func (s *Store) CreatePlan(ctx context.Context, plan *types.Plan) error
- func (s *Store) CreatePlanComment(ctx context.Context, comment *types.PlanComment) error
- func (s *Store) CreateProject(ctx context.Context, p *types.Project) error
- func (s *Store) CreateWorkspace(ctx context.Context, ws *types.Workspace) error
- func (s *Store) DeleteAISession(ctx context.Context, id string) error
- func (s *Store) DeleteComment(ctx context.Context, commentID int64) error
- func (s *Store) DeleteIssue(ctx context.Context, id string) error
- func (s *Store) DeleteLabel(ctx context.Context, name string) error
- func (s *Store) DeletePlan(ctx context.Context, id string) error
- func (s *Store) DeleteProject(ctx context.Context, idOrName string) error
- func (s *Store) DeleteWorkspace(ctx context.Context, id string) error
- func (s *Store) GetAIAgent(ctx context.Context, id string) (*types.AIAgent, error)
- func (s *Store) GetAISession(ctx context.Context, id string) (*types.AISession, error)
- func (s *Store) GetBlockedIssues(ctx context.Context, filter types.WorkFilter) ([]*types.BlockedIssue, error)
- func (s *Store) GetComments(ctx context.Context, issueID string) ([]*types.Comment, error)
- func (s *Store) GetDependencies(ctx context.Context, issueID string) ([]*types.Dependency, error)
- func (s *Store) GetDependents(ctx context.Context, issueID string) ([]*types.Dependency, error)
- func (s *Store) GetEvents(ctx context.Context, issueID string, limit int) ([]*types.Event, error)
- func (s *Store) GetIssue(ctx context.Context, id string) (*types.Issue, error)
- func (s *Store) GetIssueByExternalRef(ctx context.Context, externalRef string) (*types.Issue, error)
- func (s *Store) GetIssueDetails(ctx context.Context, id string) (*types.IssueDetails, error)
- func (s *Store) GetIssueLabels(ctx context.Context, issueID string) ([]string, error)
- func (s *Store) GetLabel(ctx context.Context, name string) (*types.Label, error)
- func (s *Store) GetLabelsForIssues(ctx context.Context, issueIDs []string) (map[string][]string, error)
- func (s *Store) GetNextChildID(ctx context.Context, parentID string) (string, error)
- func (s *Store) GetOpenChildIssues(ctx context.Context, parentID string) ([]*types.Issue, error)
- func (s *Store) GetPlan(ctx context.Context, id string) (*types.Plan, error)
- func (s *Store) GetProject(ctx context.Context, id string) (*types.Project, error)
- func (s *Store) GetProjectByName(ctx context.Context, name string) (*types.Project, error)
- func (s *Store) GetReadyWork(ctx context.Context, filter types.WorkFilter) ([]*types.Issue, error)
- func (s *Store) GetStatistics(ctx context.Context, projectID string) (*types.Statistics, error)
- func (s *Store) GetWorkspace(ctx context.Context, id string) (*types.Workspace, error)
- func (s *Store) IsBlocked(ctx context.Context, issueID string) (bool, []string, error)
- func (s *Store) ListAIAgents(ctx context.Context, sessionID string) ([]*types.AIAgent, error)
- func (s *Store) ListAISessions(ctx context.Context, limit, offset int) ([]*types.AISession, error)
- func (s *Store) ListIssues(ctx context.Context, filter types.IssueFilter) ([]*types.Issue, error)
- func (s *Store) ListLabels(ctx context.Context) ([]*types.Label, error)
- func (s *Store) ListPlanComments(ctx context.Context, planID string) ([]*types.PlanComment, error)
- func (s *Store) ListProjects(ctx context.Context) ([]*types.Project, error)
- func (s *Store) ListWorkspaces(ctx context.Context, projectID string) ([]*types.Workspace, error)
- func (s *Store) MergeProjects(ctx context.Context, targetID string, sourceIDs []string, actor string) (*types.MergeResult, error)
- func (s *Store) Path() string
- func (s *Store) RemoveDependency(ctx context.Context, issueID, dependsOnID string, actor string) error
- func (s *Store) RemoveLabelFromIssue(ctx context.Context, issueID, label, actor string) error
- func (s *Store) ReopenIssue(ctx context.Context, id string, actor string) error
- func (s *Store) ResolveProjectByPath(ctx context.Context, path string) (*types.Workspace, error)
- func (s *Store) UpdateComment(ctx context.Context, commentID int64, text string) error
- func (s *Store) UpdateIssue(ctx context.Context, id string, updates map[string]any, actor string) error
- func (s *Store) UpdateLabel(ctx context.Context, label *types.Label) error
- func (s *Store) UpdatePlanStatus(ctx context.Context, id string, status string) error
- func (s *Store) UpdateProject(ctx context.Context, p *types.Project) error
- func (s *Store) UpdateWorkspace(ctx context.Context, ws *types.Workspace) error
- func (s *Store) UpdateWorkspaceLastAccessed(ctx context.Context, id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsHierarchicalID ¶
IsHierarchicalID checks if an issue ID is hierarchical (has a parent). Hierarchical IDs have the format {parentID}.{N} where N is a numeric child suffix. Returns true and the parent ID if hierarchical, false and empty string otherwise.
func MigrationVersion ¶
MigrationVersion returns the current migration version.
func PrepareSearchQuery ¶ added in v0.11.0
PrepareSearchQuery transforms user input into an FTS5 MATCH query. - Each unquoted term gets a `*` suffix for prefix matching - Quoted phrases are passed through for exact matching - Empty input returns empty string
func RunMigrations ¶
RunMigrations applies all pending database migrations.
Types ¶
type BackupResult ¶ added in v0.12.0
type BackupResult struct {
Path string // Path to the backup file
OriginalSize int64 // Size of the original database file in bytes
BackupSize int64 // Size of the compressed backup in bytes
}
BackupResult holds metadata about a completed backup.
func BackupDatabase ¶ added in v0.12.0
func BackupDatabase(dbPath string) (*BackupResult, error)
BackupDatabase creates a timestamped, gzipped backup of a SQLite database file. It opens its own connection to perform the WAL checkpoint, so no existing connection is needed. Use BackupDatabaseConn if you already have a connection.
func BackupDatabaseConn ¶ added in v0.12.0
func BackupDatabaseConn(sqlDB *sql.DB, dbPath string) (*BackupResult, error)
BackupDatabaseConn creates a timestamped, gzipped backup of a SQLite database using an existing connection. The connection is used for the WAL checkpoint but is NOT closed by this function.
The backup file is written to the same directory as the database with the format: <dbfile>.<YYYYMMDD_HHMMSS>.gz
Returns nil result (no error) if the database file doesn't exist or is empty.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements the storage.Storage interface using SQLite.
func New ¶
New creates a new SQLite store at the given path. If the path is empty, uses ~/.arc/data.db
func (*Store) AddComment ¶
func (s *Store) AddComment(ctx context.Context, issueID, author, text string) (*types.Comment, error)
AddComment adds a comment to an issue and records a corresponding event.
func (*Store) AddDependency ¶
AddDependency adds a dependency between two issues. It validates that the issue does not depend on itself and that the dependency type is valid.
func (*Store) AddLabelToIssue ¶
AddLabelToIssue adds a label to an issue.
func (*Store) CloseIssue ¶
func (s *Store) CloseIssue(ctx context.Context, id string, reason string, cascade bool, actor string) error
CloseIssue closes an issue. When cascade is false, it checks for open child issues and returns an *types.OpenChildrenError if any are found. When cascade is true, it recursively closes all open descendants leaf-first before closing the target issue. Each cascade-closed child gets a reason of "<reason> (cascade closed by <parent-id>)" where parent-id is the original issue being closed.
func (*Store) CreateAIAgent ¶
CreateAIAgent creates a new AI agent record.
func (*Store) CreateAISession ¶
CreateAISession creates a new AI session record.
func (*Store) CreateIssue ¶
CreateIssue creates a new issue. If ParentID is set, generates a hierarchical child ID (e.g., parent.1) and automatically creates a parent-child dependency.
func (*Store) CreateLabel ¶
CreateLabel creates a new global label definition.
func (*Store) CreatePlan ¶ added in v0.7.0
CreatePlan persists a new plan. The caller must set plan.ID before calling.
func (*Store) CreatePlanComment ¶
CreatePlanComment persists a new comment on a plan.
func (*Store) CreateProject ¶ added in v0.12.0
CreateProject creates a new project.
func (*Store) CreateWorkspace ¶
CreateWorkspace creates a new workspace (directory path entry).
func (*Store) DeleteAISession ¶
DeleteAISession deletes an AI session and its associated agents. Agents are deleted explicitly to ensure cascade behavior regardless of whether the SQLite driver honours the ON DELETE CASCADE pragma.
func (*Store) DeleteComment ¶
DeleteComment deletes a comment.
func (*Store) DeleteIssue ¶
DeleteIssue deletes an issue.
func (*Store) DeleteLabel ¶
DeleteLabel deletes a label.
func (*Store) DeletePlan ¶ added in v0.7.0
DeletePlan deletes a plan and its associated comments. Comments are deleted explicitly to ensure cascade behavior regardless of whether the SQLite driver honours the ON DELETE CASCADE pragma.
func (*Store) DeleteProject ¶ added in v0.12.0
DeleteProject deletes a project and all its issues. Accepts either project ID (e.g., "proj-00blnw") or name (e.g., "my-project-a1b2c3").
func (*Store) DeleteWorkspace ¶
DeleteWorkspace removes a workspace entry.
func (*Store) GetAIAgent ¶
GetAIAgent retrieves an AI agent by ID.
func (*Store) GetAISession ¶
GetAISession retrieves an AI session by ID.
func (*Store) GetBlockedIssues ¶
func (s *Store) GetBlockedIssues(ctx context.Context, filter types.WorkFilter) ([]*types.BlockedIssue, error)
GetBlockedIssues returns issues that are blocked by other issues. For each blocked issue, it also fetches the IDs of the issues blocking it.
func (*Store) GetComments ¶
GetComments returns all comments for an issue.
func (*Store) GetDependencies ¶
GetDependencies returns the dependencies of an issue.
func (*Store) GetDependents ¶
GetDependents returns issues that depend on the given issue.
func (*Store) GetEvents ¶
GetEvents returns the event history for an issue, ordered by creation time. Defaults to a limit of 50 events if limit is zero or negative.
func (*Store) GetIssueByExternalRef ¶
func (s *Store) GetIssueByExternalRef(ctx context.Context, externalRef string) (*types.Issue, error)
GetIssueByExternalRef retrieves an issue by its external reference.
func (*Store) GetIssueDetails ¶
GetIssueDetails retrieves an issue with all its relational data.
func (*Store) GetIssueLabels ¶
GetIssueLabels returns all labels for an issue.
func (*Store) GetLabelsForIssues ¶
func (s *Store) GetLabelsForIssues(ctx context.Context, issueIDs []string) (map[string][]string, error)
GetLabelsForIssues fetches labels for multiple issues in a single query. Returns a map of issue_id -> []labels. Uses dynamic SQL (not sqlc) because the issue ID list is variable-length and sqlc.slice has positional placeholder incompatibilities (see ListIssues).
func (*Store) GetNextChildID ¶
GetNextChildID generates the next hierarchical child ID for a given parent. Returns formatted ID as parentID.{counter} (e.g., arc-a3f8e9.1)
func (*Store) GetOpenChildIssues ¶ added in v0.11.0
GetOpenChildIssues returns open (non-closed) child issues of a given parent via parent-child dependencies.
func (*Store) GetPlan ¶ added in v0.7.0
GetPlan retrieves a plan by ID. Returns an error if not found.
func (*Store) GetProject ¶ added in v0.12.0
GetProject retrieves a project by ID.
func (*Store) GetProjectByName ¶ added in v0.12.0
GetProjectByName retrieves a project by name.
func (*Store) GetReadyWork ¶
GetReadyWork returns issues that are ready to work on (not blocked). Results are sorted according to the filter's SortPolicy (hybrid, priority, or oldest). Additional filters for issue type, priority, assignee, and status are applied in-memory.
func (*Store) GetStatistics ¶
GetStatistics returns aggregate statistics for a project. Includes counts by status, ready issue count, and average lead time.
func (*Store) GetWorkspace ¶
GetWorkspace retrieves a workspace by its unique ID. Returns an error if no workspace exists with the given ID.
func (*Store) IsBlocked ¶
IsBlocked checks if an issue is blocked by any open issues. Returns true and the list of blocking issue IDs if blocked, false otherwise.
func (*Store) ListAIAgents ¶
ListAIAgents returns AI agents for a session ordered by created_at ascending.
func (*Store) ListAISessions ¶
ListAISessions returns AI sessions ordered by started_at descending.
func (*Store) ListIssues ¶
ListIssues returns issues matching the filter. All filter fields are composed with AND semantics so multiple filters (e.g. --parent + --status) work together via a dynamic SQL query. We use dynamic SQL because sqlc.slice and sqlc.narg positional placeholders are incompatible when mixed in the same query (positional ?N offsets shift when slice placeholders expand to multiple values).
func (*Store) ListLabels ¶
ListLabels returns all global labels.
func (*Store) ListPlanComments ¶
ListPlanComments returns all comments for a plan, ordered by creation time.
func (*Store) ListProjects ¶ added in v0.12.0
ListProjects returns all projects.
func (*Store) ListWorkspaces ¶
ListWorkspaces returns all workspaces for a project.
func (*Store) MergeProjects ¶ added in v0.12.0
func (s *Store) MergeProjects( ctx context.Context, targetID string, sourceIDs []string, actor string, ) (*types.MergeResult, error)
MergeProjects moves all issues and plans from source projects into the target project, deletes the sources, and returns a summary. The entire operation runs inside a single transaction for atomicity.
func (*Store) RemoveDependency ¶
func (s *Store) RemoveDependency(ctx context.Context, issueID, dependsOnID string, actor string) error
RemoveDependency removes a dependency between two issues.
func (*Store) RemoveLabelFromIssue ¶
RemoveLabelFromIssue removes a label from an issue.
func (*Store) ReopenIssue ¶
ReopenIssue reopens a closed issue.
func (*Store) ResolveProjectByPath ¶ added in v0.12.0
ResolveProjectByPath finds a workspace entry by filesystem path.
func (*Store) UpdateComment ¶
UpdateComment updates a comment's text.
func (*Store) UpdateIssue ¶
func (s *Store) UpdateIssue(ctx context.Context, id string, updates map[string]any, actor string) error
UpdateIssue updates an issue with the given updates.
func (*Store) UpdateLabel ¶
UpdateLabel updates a label.
func (*Store) UpdatePlanStatus ¶
UpdatePlanStatus changes a plan's status.
func (*Store) UpdateProject ¶ added in v0.12.0
UpdateProject updates a project.
func (*Store) UpdateWorkspace ¶
UpdateWorkspace updates a workspace entry.