Documentation
¶
Overview ¶
Package db provides the SQLite persistence layer for td, handling issue storage, migrations, multi-process locking, and query execution.
Index ¶
- Constants
- Variables
- func AnalyticsEnabled() bool
- func BaseSchema() string
- func BoardIssuePosID(boardID, issueID string) string
- func ClearAgentErrors(baseDir string) error
- func ClearCommandUsage(baseDir string) error
- func ClearSecurityEvents(baseDir string) error
- func CountAgentErrors(baseDir string) (int, error)
- func CountCommandUsage(baseDir string) (int, error)
- func DependencyID(issueID, dependsOnID, relationType string) string
- func IsAbsolutePath(p string) bool
- func IssueFileID(issueID, filePath string) string
- func LogAgentError(baseDir string, args []string, errMsg string, sessionID string) error
- func LogCommandUsage(baseDir string, event CommandUsageEvent) error
- func LogCommandUsageAsync(baseDir string, event CommandUsageEvent)
- func LogSecurityEvent(baseDir string, event SecurityEvent) error
- func NormalizeFilePathForID(p string) string
- func NormalizeIssueID(id string) string
- func PruneSyncHistory(tx *sql.Tx, maxRows int) error
- func RecordSyncHistoryTx(tx *sql.Tx, entries []SyncHistoryEntry) error
- func ResolveBaseDir(baseDir string) string
- func SanitizeFlags(flags map[string]string) map[string]string
- func ToRepoRelative(absPath, repoRoot string) (string, error)
- func WsiID(workSessionID, issueID string) string
- type AgentError
- type AnalyticsSummary
- type BoardIssuePosition
- type CommandUsageEvent
- type DB
- func (db *DB) AddComment(comment *models.Comment) error
- func (db *DB) AddDependency(issueID, dependsOnID, relationType string) error
- func (db *DB) AddDependencyLogged(issueID, dependsOnID, relationType, sessionID string) error
- func (db *DB) AddGitSnapshot(snapshot *models.GitSnapshot) error
- func (db *DB) AddHandoff(handoff *models.Handoff) error
- func (db *DB) AddLog(log *models.Log) error
- func (db *DB) ApplyBoardPositions(boardID string, issues []models.Issue) ([]models.BoardIssueView, error)
- func (db *DB) ArchiveNote(id string) error
- func (db *DB) BaseDir() string
- func (db *DB) CascadeUnblockDependents(closedIssueID, sessionID string) (int, []string)
- func (db *DB) CascadeUpParentStatus(issueID string, targetStatus models.Status, sessionID string) (int, []string)
- func (db *DB) ClearActionLogSyncState() (int64, error)
- func (db *DB) ClearSyncState() error
- func (db *DB) Close() error
- func (db *DB) ComputeInsertPosition(boardID string, slot int) (int, []RespaceResult, error)
- func (db *DB) Conn() *sql.DB
- func (db *DB) CountPendingEvents() (int64, error)
- func (db *DB) CountSyncedEvents() (int64, error)
- func (db *DB) CreateBoard(name, queryStr string) (*models.Board, error)
- func (db *DB) CreateBoardLogged(name, queryStr, sessionID string) (*models.Board, error)
- func (db *DB) CreateIssue(issue *models.Issue) error
- func (db *DB) CreateIssueLogged(issue *models.Issue, sessionID string) error
- func (db *DB) CreateNote(title, content string) (*models.Note, error)
- func (db *DB) CreateWorkSession(ws *models.WorkSession) error
- func (db *DB) DeleteBoard(id string) error
- func (db *DB) DeleteBoardLogged(boardID, sessionID string) error
- func (db *DB) DeleteHandoff(handoffID string) error
- func (db *DB) DeleteIssue(id string) error
- func (db *DB) DeleteIssueLogged(issueID, sessionID string) error
- func (db *DB) DeleteNote(id string) error
- func (db *DB) DeleteStaleSessions(before time.Time) (int64, error)
- func (db *DB) GetActiveSessions(since time.Time) ([]string, error)
- func (db *DB) GetAllDependencies() (map[string][]string, error)
- func (db *DB) GetBlockedBy(issueID string) ([]string, error)
- func (db *DB) GetBoard(id string) (*models.Board, error)
- func (db *DB) GetBoardByName(name string) (*models.Board, error)
- func (db *DB) GetBoardIssuePositions(boardID string) ([]BoardIssuePosition, error)
- func (db *DB) GetBoardIssues(boardID, sessionID string, statusFilter []models.Status) ([]models.BoardIssueView, error)
- func (db *DB) GetComments(issueID string) ([]models.Comment, error)
- func (db *DB) GetDependencies(issueID string) ([]string, error)
- func (db *DB) GetDescendantIssues(issueID string, statuses []models.Status) ([]*models.Issue, error)
- func (db *DB) GetDirectChildren(issueID string) ([]*models.Issue, error)
- func (db *DB) GetExtendedStats() (*models.ExtendedStats, error)
- func (db *DB) GetIssue(id string) (*models.Issue, error)
- func (db *DB) GetIssuePosition(boardID, issueID string) (int, error)
- func (db *DB) GetIssueSessionLog(sessionID string) ([]string, error)
- func (db *DB) GetIssueStatuses(ids []string) (map[string]models.Status, error)
- func (db *DB) GetIssueTitles(ids []string) (map[string]string, error)
- func (db *DB) GetIssuesByIDs(ids []string) ([]models.Issue, error)
- func (db *DB) GetIssuesWithOpenDeps() (map[string]bool, error)
- func (db *DB) GetLastAction(sessionID string) (*models.ActionLog, error)
- func (db *DB) GetLastViewedBoard() (*models.Board, error)
- func (db *DB) GetLatestHandoff(issueID string) (*models.Handoff, error)
- func (db *DB) GetLinkedFiles(issueID string) ([]models.IssueFile, error)
- func (db *DB) GetLogs(issueID string, limit int) ([]models.Log, error)
- func (db *DB) GetLogsByWorkSession(wsID string) ([]models.Log, error)
- func (db *DB) GetMaxBoardPosition(boardID string) (int, error)
- func (db *DB) GetNote(id string) (*models.Note, error)
- func (db *DB) GetRecentActions(sessionID string, limit int) ([]models.ActionLog, error)
- func (db *DB) GetRecentActionsAll(limit int) ([]models.ActionLog, error)
- func (db *DB) GetRecentCommentsAll(limit int) ([]models.Comment, error)
- func (db *DB) GetRecentConflicts(limit int, since *time.Time) ([]SyncConflict, error)
- func (db *DB) GetRecentHandoffs(limit int, since time.Time) ([]models.Handoff, error)
- func (db *DB) GetRecentLogsAll(limit int) ([]models.Log, error)
- func (db *DB) GetRejectedInProgressIssueIDs() (map[string]bool, error)
- func (db *DB) GetSchemaVersion() (int, error)
- func (db *DB) GetSessionByBranchAgent(branch, agentType string, agentPID int) (*SessionRow, error)
- func (db *DB) GetSessionByID(id string) (*SessionRow, error)
- func (db *DB) GetSessionHistory(issueID string) ([]models.IssueSessionHistory, error)
- func (db *DB) GetStartSnapshot(issueID string) (*models.GitSnapshot, error)
- func (db *DB) GetStats() (map[string]int, error)
- func (db *DB) GetSyncHistory(afterID int64, limit int) ([]SyncHistoryEntry, error)
- func (db *DB) GetSyncHistoryTail(limit int) ([]SyncHistoryEntry, error)
- func (db *DB) GetSyncState() (*SyncState, error)
- func (db *DB) GetWorkSession(id string) (*models.WorkSession, error)
- func (db *DB) GetWorkSessionIssues(wsID string) ([]string, error)
- func (db *DB) HasChildren(issueID string) (bool, error)
- func (db *DB) LinkFile(issueID, filePath string, role models.FileRole, sha string) error
- func (db *DB) LinkFileLogged(issueID, filePath string, role models.FileRole, sha, sessionID string) error
- func (db *DB) ListAllSessions() ([]SessionRow, error)
- func (db *DB) ListBoards() ([]models.Board, error)
- func (db *DB) ListIssues(opts ListIssuesOptions) ([]models.Issue, error)
- func (db *DB) ListNotes(opts ListNotesOptions) ([]models.Note, error)
- func (db *DB) ListWorkSessions(limit int) ([]models.WorkSession, error)
- func (db *DB) LogAction(action *models.ActionLog) error
- func (db *DB) MarkActionUndone(actionID string) error
- func (db *DB) MigrateFileSystemSessions(baseDir string) error
- func (db *DB) PinNote(id string) error
- func (db *DB) RecordSessionAction(issueID, sessionID string, action models.IssueSessionAction) error
- func (db *DB) RemoveDependency(issueID, dependsOnID string) error
- func (db *DB) RemoveDependencyLogged(issueID, dependsOnID, sessionID string) error
- func (db *DB) RemoveIssuePosition(boardID, issueID string) error
- func (db *DB) RemoveIssuePositionLogged(boardID, issueID, sessionID string) error
- func (db *DB) ResolveBoardRef(ref string) (*models.Board, error)
- func (db *DB) RespaceBoardPositions(boardID string) ([]RespaceResult, error)
- func (db *DB) RestoreBoard(board *models.Board) error
- func (db *DB) RestoreIssue(id string) error
- func (db *DB) RestoreIssueLogged(issueID, sessionID string) error
- func (db *DB) RunMigrations() (int, error)
- func (db *DB) SearchIssues(query string, opts ListIssuesOptions) ([]models.Issue, error)
- func (db *DB) SearchIssuesRanked(query string, opts ListIssuesOptions) ([]SearchResult, error)
- func (db *DB) SetIssuePosition(boardID, issueID string, position int) error
- func (db *DB) SetIssuePositionLogged(boardID, issueID string, position int, sessionID string) error
- func (db *DB) SetMaxOpenConns(n int)
- func (db *DB) SetSchemaVersion(version int) error
- func (db *DB) SetSyncState(projectID string) error
- func (db *DB) SwapIssuePositions(boardID, id1, id2 string) error
- func (db *DB) TagIssueToWorkSession(wsID, issueID, sessionID string) error
- func (db *DB) UnarchiveNote(id string) error
- func (db *DB) UnlinkFile(issueID, filePath string) error
- func (db *DB) UnlinkFileLogged(issueID, filePath, sessionID string) error
- func (db *DB) UnpinNote(id string) error
- func (db *DB) UntagIssueFromWorkSession(wsID, issueID, sessionID string) error
- func (db *DB) UpdateBoard(board *models.Board) error
- func (db *DB) UpdateBoardLastViewed(boardID string) error
- func (db *DB) UpdateBoardLogged(board *models.Board, sessionID string) error
- func (db *DB) UpdateBoardViewMode(boardID, viewMode string) error
- func (db *DB) UpdateIssue(issue *models.Issue) error
- func (db *DB) UpdateIssueLogged(issue *models.Issue, sessionID string, actionType models.ActionType) error
- func (db *DB) UpdateNote(id, title, content string) (*models.Note, error)
- func (db *DB) UpdateSessionActivity(id string, t time.Time) error
- func (db *DB) UpdateSessionName(id, name string) error
- func (db *DB) UpdateSyncPulled(lastServerSeq int64) error
- func (db *DB) UpdateSyncPushed(lastActionID int64) error
- func (db *DB) UpdateWorkSession(ws *models.WorkSession) error
- func (db *DB) UpsertSession(sess *SessionRow) error
- func (db *DB) WasSessionInvolved(issueID, sessionID string) (bool, error)
- type ListIssuesOptions
- type ListNotesOptions
- type Migration
- type RespaceResult
- type SearchResult
- type SecurityEvent
- type SessionRow
- type SyncConflict
- type SyncHistoryEntry
- type SyncState
Constants ¶
const PositionGap = 65536
PositionGap is the spacing between sparse sort keys for board positions.
const SchemaVersion = 28
SchemaVersion is the current database schema version
Variables ¶
var Migrations = []Migration{
{
Version: 2,
Description: "Add action_log table for undo support",
SQL: `
CREATE TABLE IF NOT EXISTS action_log (
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id TEXT NOT NULL,
action_type TEXT NOT NULL,
entity_type TEXT NOT NULL,
entity_id TEXT NOT NULL,
previous_data TEXT DEFAULT '',
new_data TEXT DEFAULT '',
timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
undone INTEGER DEFAULT 0
);
CREATE INDEX IF NOT EXISTS idx_action_log_session ON action_log(session_id);
CREATE INDEX IF NOT EXISTS idx_action_log_timestamp ON action_log(timestamp);
`,
},
{
Version: 3,
Description: "Allow work session logs without issue_id",
SQL: `
-- SQLite doesn't support ALTER COLUMN, so we need to recreate the table
CREATE TABLE logs_new (
id INTEGER PRIMARY KEY AUTOINCREMENT,
issue_id TEXT DEFAULT '',
session_id TEXT NOT NULL,
work_session_id TEXT DEFAULT '',
message TEXT NOT NULL,
type TEXT NOT NULL DEFAULT 'progress',
timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO logs_new SELECT * FROM logs;
DROP TABLE logs;
ALTER TABLE logs_new RENAME TO logs;
CREATE INDEX IF NOT EXISTS idx_logs_issue ON logs(issue_id);
CREATE INDEX IF NOT EXISTS idx_logs_work_session ON logs(work_session_id);
`,
},
{
Version: 4,
Description: "Add minor flag to issues for self-reviewable tasks",
SQL: `ALTER TABLE issues ADD COLUMN minor INTEGER DEFAULT 0;`,
},
{
Version: 5,
Description: "Add created_branch to issues",
SQL: `ALTER TABLE issues ADD COLUMN created_branch TEXT DEFAULT '';`,
},
{
Version: 6,
Description: "Add creator_session for review enforcement",
SQL: `ALTER TABLE issues ADD COLUMN creator_session TEXT DEFAULT '';`,
},
{
Version: 7,
Description: "Add session history for review enforcement",
SQL: `CREATE TABLE IF NOT EXISTS issue_session_history (
id TEXT PRIMARY KEY,
issue_id TEXT NOT NULL,
session_id TEXT NOT NULL,
action TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (issue_id) REFERENCES issues(id)
);
CREATE INDEX IF NOT EXISTS idx_ish_issue ON issue_session_history(issue_id);
CREATE INDEX IF NOT EXISTS idx_ish_session ON issue_session_history(session_id);`,
},
{
Version: 8,
Description: "Add timestamp indexes for activity queries",
SQL: `CREATE INDEX IF NOT EXISTS idx_handoffs_timestamp ON handoffs(timestamp);
CREATE INDEX IF NOT EXISTS idx_issues_deleted_status ON issues(deleted_at, status);`,
},
{
Version: 9,
Description: "Add boards and board_issues tables",
SQL: `
-- Boards table
CREATE TABLE IF NOT EXISTS boards (
id TEXT PRIMARY KEY,
name TEXT NOT NULL COLLATE NOCASE UNIQUE,
last_viewed_at DATETIME,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- Board-Issue membership with ordering
CREATE TABLE IF NOT EXISTS board_issues (
board_id TEXT NOT NULL,
issue_id TEXT NOT NULL,
position INTEGER NOT NULL,
added_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (board_id, issue_id),
FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE,
FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_board_issues_position ON board_issues(board_id, position);
`,
},
{
Version: 10,
Description: "Query-based boards with sparse ordering and sprint field",
SQL: `
-- Add query and is_builtin columns to boards
ALTER TABLE boards ADD COLUMN query TEXT NOT NULL DEFAULT '';
ALTER TABLE boards ADD COLUMN is_builtin INTEGER NOT NULL DEFAULT 0;
-- Rename board_issues to board_issue_positions for semantic clarity
DROP INDEX IF EXISTS idx_board_issues_position;
ALTER TABLE board_issues RENAME TO board_issue_positions;
-- Recreate index on positions
CREATE UNIQUE INDEX IF NOT EXISTS idx_board_positions_position
ON board_issue_positions(board_id, position);
-- Add sprint field to issues
ALTER TABLE issues ADD COLUMN sprint TEXT DEFAULT '';
-- Create built-in "All Issues" board (empty query = all issues)
INSERT INTO boards (id, name, query, is_builtin, created_at, updated_at)
VALUES ('bd-all-issues', 'All Issues', '', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
ON CONFLICT(name) DO UPDATE SET
query = excluded.query,
is_builtin = 1,
updated_at = CURRENT_TIMESTAMP;
`,
},
{
Version: 11,
Description: "Add view_mode to boards for swimlanes/backlog toggle",
SQL: `ALTER TABLE boards ADD COLUMN view_mode TEXT NOT NULL DEFAULT 'swimlanes';`,
},
{
Version: 12,
Description: "Add missing indices for monitor query performance",
SQL: `CREATE INDEX IF NOT EXISTS idx_action_log_entity_type ON action_log(entity_id, action_type);
CREATE INDEX IF NOT EXISTS idx_logs_timestamp ON logs(timestamp);
CREATE INDEX IF NOT EXISTS idx_comments_created_at ON comments(created_at);`,
},
{
Version: 13,
Description: "Extend sessions table for full DB-backed session storage",
SQL: "",
},
{
Version: 14,
Description: "Repair sessions table for DBs where v13 did not apply correctly",
SQL: "",
},
{
Version: 15,
Description: "Migrate integer PK tables to text IDs for sync compatibility",
SQL: "",
},
{
Version: 16,
Description: "Add sync_state table and sync columns to action_log",
SQL: `
CREATE TABLE IF NOT EXISTS sync_state (
project_id TEXT PRIMARY KEY,
last_pushed_action_id INTEGER DEFAULT 0,
last_pulled_server_seq INTEGER DEFAULT 0,
last_sync_at DATETIME,
sync_disabled INTEGER DEFAULT 0
);
ALTER TABLE action_log ADD COLUMN synced_at DATETIME;
ALTER TABLE action_log ADD COLUMN server_seq INTEGER;
`,
},
{
Version: 17,
Description: "Add sync_conflicts table for overwrite tracking",
SQL: `
CREATE TABLE IF NOT EXISTS sync_conflicts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
entity_type TEXT NOT NULL,
entity_id TEXT NOT NULL,
server_seq INTEGER NOT NULL,
local_data JSON,
remote_data JSON,
overwritten_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_sync_conflicts_entity ON sync_conflicts(entity_type, entity_id);
CREATE INDEX IF NOT EXISTS idx_sync_conflicts_time ON sync_conflicts(overwritten_at);
CREATE INDEX IF NOT EXISTS idx_sync_conflicts_seq ON sync_conflicts(server_seq);
`,
},
{
Version: 18,
Description: "Add deterministic ID columns to composite-key tables for sync",
SQL: "",
},
{
Version: 19,
Description: "Convert absolute file paths to repo-relative in issue_files",
SQL: "",
},
{
Version: 20,
Description: "Normalize legacy action_log entries for composite-key entities",
SQL: "",
},
{
Version: 21,
Description: "Add sync_history table for tracking sync operations",
SQL: `
CREATE TABLE IF NOT EXISTS sync_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
direction TEXT NOT NULL,
action_type TEXT NOT NULL,
entity_type TEXT NOT NULL,
entity_id TEXT NOT NULL,
server_seq INTEGER,
device_id TEXT DEFAULT '',
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_sync_history_ts ON sync_history(timestamp);
`,
},
{
Version: 22,
Description: "Sparse positioning: drop unique position index, re-space with gaps",
SQL: `
DROP INDEX IF EXISTS idx_board_positions_position;
UPDATE board_issue_positions SET position = position * 65536;
`,
},
{
Version: 23,
Description: "Drop UNIQUE(name) on boards to prevent sync data loss",
SQL: `
CREATE TABLE boards_new (
id TEXT PRIMARY KEY,
name TEXT NOT NULL COLLATE NOCASE,
last_viewed_at DATETIME,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
query TEXT NOT NULL DEFAULT '',
is_builtin INTEGER NOT NULL DEFAULT 0,
view_mode TEXT NOT NULL DEFAULT 'swimlanes'
);
INSERT INTO boards_new SELECT * FROM boards;
DROP TABLE boards;
ALTER TABLE boards_new RENAME TO boards;
`,
},
{
Version: 24,
Description: "Add deterministic id column to work_session_issues for sync",
SQL: "",
},
{
Version: 25,
Description: "Add deleted_at to board_issue_positions for soft delete sync",
SQL: "",
},
{
Version: 26,
Description: "Enforce NOT NULL on action_log.id by fixing NULL values and recreating table",
SQL: "",
},
{
Version: 27,
Description: "Normalize NULL session fields in issues",
SQL: `
UPDATE issues SET implementer_session = '' WHERE implementer_session IS NULL;
UPDATE issues SET reviewer_session = '' WHERE reviewer_session IS NULL;
UPDATE issues SET creator_session = '' WHERE creator_session IS NULL;
`,
},
{
Version: 28,
Description: "Add notes table for sidecar notes sync",
SQL: `
CREATE TABLE IF NOT EXISTS notes (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
content TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
pinned INTEGER DEFAULT 0,
archived INTEGER DEFAULT 0,
deleted_at TEXT
);
CREATE INDEX IF NOT EXISTS idx_notes_updated ON notes(updated_at DESC);
CREATE INDEX IF NOT EXISTS idx_notes_deleted ON notes(deleted_at);
`,
},
}
Migrations is the list of all database migrations in order
var QueryValidator func(queryStr string) error
QueryValidator is set by main to validate TDQ queries without import cycle. Returns nil if valid, error describing parse failure otherwise.
Functions ¶
func AnalyticsEnabled ¶ added in v0.7.0
func AnalyticsEnabled() bool
AnalyticsEnabled returns true unless TD_ANALYTICS is explicitly disabled
func BaseSchema ¶ added in v0.30.0
func BaseSchema() string
BaseSchema returns the initial database schema DDL. Used by the sync test harness to avoid schema duplication.
func BoardIssuePosID ¶ added in v0.30.0
BoardIssuePosID returns a deterministic ID for a board_issue_positions row.
func ClearAgentErrors ¶ added in v0.4.16
ClearAgentErrors removes the agent errors file.
func ClearCommandUsage ¶ added in v0.7.0
ClearCommandUsage removes the usage file
func ClearSecurityEvents ¶ added in v0.5.0
ClearSecurityEvents removes the security events file
func CountAgentErrors ¶ added in v0.4.16
CountAgentErrors returns the number of logged errors.
func CountCommandUsage ¶ added in v0.7.0
CountCommandUsage returns the number of logged events
func DependencyID ¶ added in v0.30.0
DependencyID returns a deterministic ID for an issue_dependencies row.
func IsAbsolutePath ¶ added in v0.30.0
IsAbsolutePath returns true if the path looks like an absolute path (starts with / on Unix or a drive letter on Windows).
func IssueFileID ¶ added in v0.30.0
IssueFileID returns a deterministic ID for an issue_files row. The file path is normalized to forward slashes before hashing so the same ID is generated regardless of OS path separators.
func LogAgentError ¶ added in v0.4.16
LogAgentError appends a failed command to the agent errors file. baseDir is the project root. If the .todos directory doesn't exist, the error is silently dropped (project not initialized).
func LogCommandUsage ¶ added in v0.7.0
func LogCommandUsage(baseDir string, event CommandUsageEvent) error
LogCommandUsage appends a usage event to the JSONL file
func LogCommandUsageAsync ¶ added in v0.7.0
func LogCommandUsageAsync(baseDir string, event CommandUsageEvent)
LogCommandUsageAsync logs without blocking the caller
func LogSecurityEvent ¶ added in v0.5.0
func LogSecurityEvent(baseDir string, event SecurityEvent) error
LogSecurityEvent appends a security event to the jsonl file
func NormalizeFilePathForID ¶ added in v0.30.0
NormalizeFilePathForID normalizes a file path to forward slashes for use in deterministic ID generation. This ensures the same ID is generated regardless of OS path separators.
func NormalizeIssueID ¶ added in v0.4.17
NormalizeIssueID ensures an issue ID has the td- prefix Accepts bare hex IDs like "abc123" and returns "td-abc123"
func PruneSyncHistory ¶ added in v0.30.0
PruneSyncHistory deletes rows not in the newest maxRows entries.
func RecordSyncHistoryTx ¶ added in v0.30.0
func RecordSyncHistoryTx(tx *sql.Tx, entries []SyncHistoryEntry) error
RecordSyncHistoryTx batch-inserts sync history entries within the provided transaction. Returns nil if entries is empty.
func ResolveBaseDir ¶ added in v0.12.0
ResolveBaseDir checks for a .td-root file in the given directory. If found, it returns the path contained in that file (pointing to the main worktree's root). Otherwise, returns the original baseDir unchanged. This enables git worktrees to share a single td database with the main repo.
func SanitizeFlags ¶ added in v0.7.0
SanitizeFlags redacts sensitive flag values
func ToRepoRelative ¶ added in v0.30.0
ToRepoRelative converts an absolute file path to a repo-relative path using forward slashes for cross-platform stability. Returns an error if the path is outside the repo root.
Types ¶
type AgentError ¶ added in v0.4.16
type AgentError struct {
Timestamp time.Time `json:"ts"`
Args []string `json:"args"`
Error string `json:"error"`
SessionID string `json:"session,omitempty"`
}
AgentError represents a failed command invocation
func ReadAgentErrors ¶ added in v0.4.16
func ReadAgentErrors(baseDir string) ([]AgentError, error)
ReadAgentErrors reads all agent errors from the file. Returns empty slice if file doesn't exist.
func ReadAgentErrorsFiltered ¶ added in v0.4.16
func ReadAgentErrorsFiltered(baseDir string, sessionID string, since time.Time, limit int) ([]AgentError, error)
ReadAgentErrorsFiltered reads agent errors matching the filter criteria.
type AnalyticsSummary ¶ added in v0.7.0
type AnalyticsSummary struct {
TotalCommands int `json:"total_commands"`
UniqueCommands int `json:"unique_commands"`
CommandCounts map[string]int `json:"by_command"`
FlagCounts map[string]int `json:"by_flag"`
DailyActivity map[string]int `json:"daily"`
ErrorRate float64 `json:"error_rate"`
ErrorsByCommand map[string]int `json:"errors_by_command"`
SessionActivity map[string]int `json:"by_session"`
AvgDurationMs int64 `json:"avg_dur_ms"`
NeverUsed []string `json:"never_used,omitempty"`
}
AnalyticsSummary holds aggregated analytics data
func ComputeAnalyticsSummary ¶ added in v0.7.0
func ComputeAnalyticsSummary(events []CommandUsageEvent, allCommands []string) *AnalyticsSummary
ComputeAnalyticsSummary aggregates events into summary stats
type BoardIssuePosition ¶ added in v0.10.0
BoardIssuePosition represents an explicit position for an issue on a board
type CommandUsageEvent ¶ added in v0.7.0
type CommandUsageEvent struct {
Timestamp time.Time `json:"ts"`
Command string `json:"cmd"`
Subcommand string `json:"sub,omitempty"`
Flags map[string]string `json:"flags,omitempty"`
SessionID string `json:"session,omitempty"`
Success bool `json:"ok"`
DurationMs int64 `json:"dur_ms"`
Error string `json:"err,omitempty"`
}
CommandUsageEvent represents a single CLI invocation
func ReadCommandUsage ¶ added in v0.7.0
func ReadCommandUsage(baseDir string) ([]CommandUsageEvent, error)
ReadCommandUsage reads all usage events from the file
func ReadCommandUsageFiltered ¶ added in v0.7.0
func ReadCommandUsageFiltered(baseDir string, since time.Time, limit int) ([]CommandUsageEvent, error)
ReadCommandUsageFiltered reads usage events matching filter criteria
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps the database connection
func Initialize ¶
Initialize creates the database and runs migrations
func (*DB) AddComment ¶
AddComment adds a comment to an issue
func (*DB) AddDependency ¶
AddDependency adds a dependency between issues WITHOUT logging to action_log. For local mutations, use AddDependencyLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) AddDependencyLogged ¶ added in v0.30.0
AddDependencyLogged adds a dependency and logs the action atomically within a single withWriteLock call.
func (*DB) AddGitSnapshot ¶
func (db *DB) AddGitSnapshot(snapshot *models.GitSnapshot) error
AddGitSnapshot records a git state snapshot
func (*DB) AddHandoff ¶
AddHandoff adds a handoff entry and logs it to action_log for sync/undo.
func (*DB) ApplyBoardPositions ¶ added in v0.10.0
func (db *DB) ApplyBoardPositions(boardID string, issues []models.Issue) ([]models.BoardIssueView, error)
ApplyBoardPositions takes a list of issues and applies board positions. Issues with explicit positions are sorted by position and returned first, followed by unpositioned issues in their original order. This function should be used with query.Execute() results for boards with TDQ queries.
func (*DB) ArchiveNote ¶ added in v0.33.0
ArchiveNote sets a note's archived status to true.
func (*DB) CascadeUnblockDependents ¶ added in v0.24.0
CascadeUnblockDependents checks issues that depend on closedIssueID. For each dependent in "blocked" status, if ALL its dependencies are now closed, it transitions the dependent from blocked → open. Returns the count and IDs of unblocked issues.
func (*DB) CascadeUpParentStatus ¶ added in v0.4.16
func (db *DB) CascadeUpParentStatus(issueID string, targetStatus models.Status, sessionID string) (int, []string)
CascadeUpParentStatus checks if all children of a parent epic have reached the target status, and if so, updates the parent to that status. Works recursively up the parent chain. Returns the number of parents that were cascaded and the list of cascaded parent IDs.
func (*DB) ClearActionLogSyncState ¶ added in v0.30.0
ClearActionLogSyncState sets synced_at and server_seq to NULL on all action_log entries, allowing them to be re-pushed to a new server. Returns the number of rows affected.
func (*DB) ClearSyncState ¶ added in v0.30.0
ClearSyncState removes the sync state (used for unlink).
func (*DB) Close ¶
Close closes the database connection. It performs a TRUNCATE checkpoint first to flush the WAL back into the main DB file and remove the -wal/-shm files. This prevents stale shared-memory files from corrupting the database when another process opens it later.
func (*DB) ComputeInsertPosition ¶ added in v0.30.0
ComputeInsertPosition computes a sparse sort key for inserting at visual slot (1-based). If the board is empty, returns PositionGap. If slot <= 1 (top): returns min_position - PositionGap. If slot > count (bottom): returns max_position + PositionGap. Otherwise: returns midpoint of positions[slot-2] and positions[slot-1]. If the gap between neighbors is < 2, calls RespaceBoardPositions first and recomputes.
func (*DB) Conn ¶ added in v0.30.0
Conn returns the underlying *sql.DB connection for use in transactions (e.g., by the sync library which needs raw DB access).
func (*DB) CountPendingEvents ¶ added in v0.30.0
CountPendingEvents returns the number of unsynced action_log entries.
func (*DB) CountSyncedEvents ¶ added in v0.30.0
CountSyncedEvents returns the number of action_log entries with synced_at set.
func (*DB) CreateBoard ¶ added in v0.10.0
CreateBoard creates a new board with a TDQ query WITHOUT logging to action_log. For local mutations, use CreateBoardLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) CreateBoardLogged ¶ added in v0.30.0
CreateBoardLogged creates a board and logs the action atomically within a single withWriteLock call.
func (*DB) CreateIssue ¶
CreateIssue creates a new issue WITHOUT logging to action_log. For local mutations, use CreateIssueLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) CreateIssueLogged ¶ added in v0.30.0
CreateIssueLogged creates an issue and logs the action atomically within a single withWriteLock call.
func (*DB) CreateNote ¶ added in v0.33.0
CreateNote creates a new note and logs the action for undo support.
func (*DB) CreateWorkSession ¶
func (db *DB) CreateWorkSession(ws *models.WorkSession) error
CreateWorkSession creates a new work session
func (*DB) DeleteBoard ¶ added in v0.10.0
DeleteBoard deletes a board (fails for builtin boards) WITHOUT logging to action_log. For local mutations, use DeleteBoardLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) DeleteBoardLogged ¶ added in v0.30.0
DeleteBoardLogged deletes a board and logs the action atomically within a single withWriteLock call.
func (*DB) DeleteHandoff ¶ added in v0.4.16
DeleteHandoff removes a handoff by ID (for undo support)
func (*DB) DeleteIssue ¶
DeleteIssue soft-deletes an issue WITHOUT logging to action_log. For local mutations, use DeleteIssueLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) DeleteIssueLogged ¶ added in v0.30.0
DeleteIssueLogged soft-deletes an issue and logs the action atomically within a single withWriteLock call.
func (*DB) DeleteNote ¶ added in v0.33.0
DeleteNote soft-deletes a note and logs the action for undo support.
func (*DB) DeleteStaleSessions ¶ added in v0.27.0
DeleteStaleSessions removes sessions with last_activity before the given time
func (*DB) GetActiveSessions ¶
GetActiveSessions returns distinct session IDs with activity since the given time
func (*DB) GetAllDependencies ¶ added in v0.7.0
GetAllDependencies returns all dependency relationships as a map
func (*DB) GetBlockedBy ¶
GetBlockedBy returns what issues are blocked by this issue
func (*DB) GetBoardByName ¶ added in v0.10.0
GetBoardByName retrieves a board by name (case-insensitive)
func (*DB) GetBoardIssuePositions ¶ added in v0.10.0
func (db *DB) GetBoardIssuePositions(boardID string) ([]BoardIssuePosition, error)
GetBoardIssuePositions returns all explicit (non-deleted) positions for a board
func (*DB) GetBoardIssues ¶ added in v0.10.0
func (db *DB) GetBoardIssues(boardID, sessionID string, statusFilter []models.Status) ([]models.BoardIssueView, error)
GetBoardIssues returns issues for a board with their positions. For boards with empty query, it fetches all issues directly. For boards with TDQ queries, callers should use ApplyBoardPositions with pre-executed query results to avoid circular import issues. Issues are returned: positioned first (by position), then unpositioned (by query order).
func (*DB) GetComments ¶
GetComments retrieves comments for an issue
func (*DB) GetDependencies ¶
GetDependencies returns what an issue depends on
func (*DB) GetDescendantIssues ¶ added in v0.4.16
func (db *DB) GetDescendantIssues(issueID string, statuses []models.Status) ([]*models.Issue, error)
GetDescendantIssues returns all descendant issues (children, grandchildren, etc.) filtered by the given statuses (empty = all statuses)
func (*DB) GetDirectChildren ¶ added in v0.4.16
GetDirectChildren returns the direct children of an issue (not recursive)
func (*DB) GetExtendedStats ¶ added in v0.4.1
func (db *DB) GetExtendedStats() (*models.ExtendedStats, error)
GetExtendedStats returns detailed statistics for dashboard/stats displays
func (*DB) GetIssue ¶
GetIssue retrieves an issue by ID Accepts bare IDs without the td- prefix (e.g., "abc123" becomes "td-abc123")
func (*DB) GetIssuePosition ¶ added in v0.30.0
GetIssuePosition returns the current position of an issue on a board, or 0 if not positioned.
func (*DB) GetIssueSessionLog ¶
GetIssueSessionLog returns issues touched by a session
func (*DB) GetIssueStatuses ¶ added in v0.7.0
GetIssueStatuses fetches statuses for multiple issues in a single query
func (*DB) GetIssueTitles ¶ added in v0.7.0
GetIssueTitles fetches titles for multiple issues in a single query
func (*DB) GetIssuesByIDs ¶ added in v0.7.0
GetIssuesByIDs fetches multiple issues in a single query
func (*DB) GetIssuesWithOpenDeps ¶ added in v0.16.0
GetIssuesWithOpenDeps returns a set of issue IDs that have at least one open (non-closed) dependency. This is used by the is_ready() and has_open_deps() query functions.
func (*DB) GetLastAction ¶
GetLastAction returns the most recent undoable action for a session
func (*DB) GetLastViewedBoard ¶ added in v0.10.0
GetLastViewedBoard returns the most recently viewed board
func (*DB) GetLatestHandoff ¶
GetLatestHandoff retrieves the latest handoff for an issue
func (*DB) GetLinkedFiles ¶
GetLinkedFiles returns files linked to an issue
func (*DB) GetLogsByWorkSession ¶
GetLogsByWorkSession retrieves logs for a specific work session
func (*DB) GetMaxBoardPosition ¶ added in v0.13.0
GetMaxBoardPosition returns the highest position value for a board, or 0 if no positioned issues.
func (*DB) GetNote ¶ added in v0.33.0
GetNote retrieves a note by ID. Returns error if not found or soft-deleted.
func (*DB) GetRecentActions ¶
GetRecentActions returns recent actions for a session
func (*DB) GetRecentActionsAll ¶
GetRecentActionsAll returns recent action_log entries across all sessions
func (*DB) GetRecentCommentsAll ¶
GetRecentCommentsAll returns recent comments across all issues
func (*DB) GetRecentConflicts ¶ added in v0.30.0
GetRecentConflicts returns recent sync conflicts, ordered by most recent first. If since is non-nil, only conflicts after that time are returned.
func (*DB) GetRecentHandoffs ¶
GetRecentHandoffs retrieves recent handoffs across all issues
func (*DB) GetRecentLogsAll ¶
GetRecentLogsAll returns recent logs across all issues
func (*DB) GetRejectedInProgressIssueIDs ¶ added in v0.8.0
GetRejectedInProgressIssueIDs returns IDs of in_progress issues that have a recent ActionReject without a subsequent ActionReview (needs rework)
func (*DB) GetSchemaVersion ¶
GetSchemaVersion returns the current schema version from the database
func (*DB) GetSessionByBranchAgent ¶ added in v0.27.0
func (db *DB) GetSessionByBranchAgent(branch, agentType string, agentPID int) (*SessionRow, error)
GetSessionByBranchAgent looks up a session by branch + agent type + agent PID. Returns nil, nil if not found.
func (*DB) GetSessionByID ¶ added in v0.27.0
func (db *DB) GetSessionByID(id string) (*SessionRow, error)
GetSessionByID looks up a session by ID. Returns nil, nil if not found.
func (*DB) GetSessionHistory ¶ added in v0.4.26
func (db *DB) GetSessionHistory(issueID string) ([]models.IssueSessionHistory, error)
GetSessionHistory returns all session interactions for an issue
func (*DB) GetStartSnapshot ¶
func (db *DB) GetStartSnapshot(issueID string) (*models.GitSnapshot, error)
GetStartSnapshot returns the start snapshot for an issue
func (*DB) GetSyncHistory ¶ added in v0.30.0
func (db *DB) GetSyncHistory(afterID int64, limit int) ([]SyncHistoryEntry, error)
GetSyncHistory returns entries with id > afterID, ordered by id ASC, limited to limit. Used for follow-mode polling.
func (*DB) GetSyncHistoryTail ¶ added in v0.30.0
func (db *DB) GetSyncHistoryTail(limit int) ([]SyncHistoryEntry, error)
GetSyncHistoryTail returns the last N entries in chronological order (oldest first).
func (*DB) GetSyncState ¶ added in v0.30.0
GetSyncState returns the current sync state, or nil if the project is not linked.
func (*DB) GetWorkSession ¶
func (db *DB) GetWorkSession(id string) (*models.WorkSession, error)
GetWorkSession retrieves a work session
func (*DB) GetWorkSessionIssues ¶
GetWorkSessionIssues returns issues tagged to a work session
func (*DB) HasChildren ¶ added in v0.4.16
HasChildren returns true if the issue has any child issues
func (*DB) LinkFile ¶
LinkFile links a file to an issue WITHOUT logging to action_log. For local mutations, use LinkFileLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) LinkFileLogged ¶ added in v0.30.0
func (db *DB) LinkFileLogged(issueID, filePath string, role models.FileRole, sha, sessionID string) error
LinkFileLogged links a file and logs the action atomically within a single withWriteLock call.
func (*DB) ListAllSessions ¶ added in v0.27.0
func (db *DB) ListAllSessions() ([]SessionRow, error)
ListAllSessions returns all sessions ordered by last_activity descending
func (*DB) ListBoards ¶ added in v0.10.0
ListBoards returns all boards sorted by last_viewed_at DESC
func (*DB) ListIssues ¶
func (db *DB) ListIssues(opts ListIssuesOptions) ([]models.Issue, error)
ListIssues returns issues matching the filter
func (*DB) ListNotes ¶ added in v0.33.0
func (db *DB) ListNotes(opts ListNotesOptions) ([]models.Note, error)
ListNotes returns notes matching the filter options.
func (*DB) ListWorkSessions ¶
func (db *DB) ListWorkSessions(limit int) ([]models.WorkSession, error)
ListWorkSessions returns recent work sessions
func (*DB) MarkActionUndone ¶
MarkActionUndone marks an action as undone
func (*DB) MigrateFileSystemSessions ¶ added in v0.27.0
MigrateFileSystemSessions migrates sessions from filesystem to DB. Safe to call multiple times—no-op if filesystem sessions don't exist. Uses INSERT OR IGNORE so concurrent calls are safe.
func (*DB) RecordSessionAction ¶ added in v0.4.26
func (db *DB) RecordSessionAction(issueID, sessionID string, action models.IssueSessionAction) error
RecordSessionAction logs a session's interaction with an issue
func (*DB) RemoveDependency ¶
RemoveDependency removes a dependency WITHOUT logging to action_log. For local mutations, use RemoveDependencyLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) RemoveDependencyLogged ¶ added in v0.30.0
RemoveDependencyLogged removes a dependency and logs the action atomically within a single withWriteLock call.
func (*DB) RemoveIssuePosition ¶ added in v0.10.0
RemoveIssuePosition soft-deletes an explicit position for an issue by setting deleted_at. WARNING: This does NOT log to action_log. For local mutations, use RemoveIssuePositionLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) RemoveIssuePositionLogged ¶ added in v0.30.0
RemoveIssuePositionLogged soft-deletes an issue's board position and logs the action atomically.
func (*DB) ResolveBoardRef ¶ added in v0.10.0
ResolveBoardRef resolves a board reference (ID or name)
func (*DB) RespaceBoardPositions ¶ added in v0.30.0
func (db *DB) RespaceBoardPositions(boardID string) ([]RespaceResult, error)
RespaceBoardPositions reassigns all positions on a board with fresh PositionGap gaps.
func (*DB) RestoreBoard ¶ added in v0.30.0
RestoreBoard re-inserts a previously deleted board from its stored state. This is used by undo to restore a deleted board.
func (*DB) RestoreIssue ¶
RestoreIssue restores a soft-deleted issue
func (*DB) RestoreIssueLogged ¶ added in v0.30.0
RestoreIssueLogged restores a soft-deleted issue and logs the action atomically.
func (*DB) RunMigrations ¶
RunMigrations runs any pending database migrations
func (*DB) SearchIssues ¶
SearchIssues performs full-text search across issues
func (*DB) SearchIssuesRanked ¶ added in v0.4.9
func (db *DB) SearchIssuesRanked(query string, opts ListIssuesOptions) ([]SearchResult, error)
SearchIssuesRanked performs search with relevance scoring
func (*DB) SetIssuePosition ¶ added in v0.10.0
SetIssuePosition sets an explicit sort-key position for an issue on a board. This directly sets the position value without shifting other rows. WARNING: This does NOT log to action_log. For local mutations, use SetIssuePositionLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) SetIssuePositionLogged ¶ added in v0.30.0
SetIssuePositionLogged sets an issue's board position and logs the action atomically.
func (*DB) SetMaxOpenConns ¶ added in v0.19.0
SetMaxOpenConns sets the maximum number of open connections to the database. For SQLite with single-writer semantics, this should typically be set to 1 to prevent connection pool growth in long-running applications.
func (*DB) SetSchemaVersion ¶
SetSchemaVersion sets the schema version in the database
func (*DB) SetSyncState ¶ added in v0.30.0
SetSyncState creates or replaces the sync state for a project (used for link).
func (*DB) SwapIssuePositions ¶ added in v0.10.0
SwapIssuePositions swaps the positions of two issues on a board
func (*DB) TagIssueToWorkSession ¶
TagIssueToWorkSession links an issue to a work session
func (*DB) UnarchiveNote ¶ added in v0.33.0
UnarchiveNote sets a note's archived status to false.
func (*DB) UnlinkFile ¶
UnlinkFile removes a file link WITHOUT logging to action_log. For local mutations, use UnlinkFileLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) UnlinkFileLogged ¶ added in v0.30.0
UnlinkFileLogged removes a file link and logs the action atomically within a single withWriteLock call.
func (*DB) UntagIssueFromWorkSession ¶
UntagIssueFromWorkSession removes an issue from a work session
func (*DB) UpdateBoard ¶ added in v0.10.0
UpdateBoard updates a board's name and/or query WITHOUT logging to action_log. For local mutations, use UpdateBoardLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) UpdateBoardLastViewed ¶ added in v0.10.0
UpdateBoardLastViewed updates the last_viewed_at timestamp for a board
func (*DB) UpdateBoardLogged ¶ added in v0.30.0
UpdateBoardLogged updates a board and logs the action atomically within a single withWriteLock call.
func (*DB) UpdateBoardViewMode ¶ added in v0.10.0
UpdateBoardViewMode updates the view_mode for a board (swimlanes or backlog)
func (*DB) UpdateIssue ¶
UpdateIssue updates an issue WITHOUT logging to action_log. For local mutations, use UpdateIssueLogged instead. This unlogged variant exists for sync receiver applying remote events.
func (*DB) UpdateIssueLogged ¶ added in v0.30.0
func (db *DB) UpdateIssueLogged(issue *models.Issue, sessionID string, actionType models.ActionType) error
UpdateIssueLogged updates an issue and logs the action atomically within a single withWriteLock call. It reads the current DB state for PreviousData before applying the update.
func (*DB) UpdateNote ¶ added in v0.33.0
UpdateNote updates a note's title and content, and logs the action for undo support.
func (*DB) UpdateSessionActivity ¶ added in v0.27.0
UpdateSessionActivity updates the last_activity timestamp for a session
func (*DB) UpdateSessionName ¶ added in v0.27.0
UpdateSessionName updates the name of a session
func (*DB) UpdateSyncPulled ¶ added in v0.30.0
UpdateSyncPulled updates the last pulled server sequence and sync time.
func (*DB) UpdateSyncPushed ¶ added in v0.30.0
UpdateSyncPushed updates the last pushed action ID and sync time.
func (*DB) UpdateWorkSession ¶
func (db *DB) UpdateWorkSession(ws *models.WorkSession) error
UpdateWorkSession updates a work session
func (*DB) UpsertSession ¶ added in v0.27.0
func (db *DB) UpsertSession(sess *SessionRow) error
UpsertSession inserts or replaces a session in the database
type ListIssuesOptions ¶
type ListIssuesOptions struct {
Status []models.Status
Type []models.Type
Priority string
Labels []string
IncludeDeleted bool
OnlyDeleted bool
Search string
Implementer string
Reviewer string
ReviewableBy string // Issues that this session can review
ParentID string
EpicID string // Filter by epic (parent_id matches epic, recursively)
PointsMin int
PointsMax int
CreatedAfter time.Time
CreatedBefore time.Time
UpdatedAfter time.Time
UpdatedBefore time.Time
ClosedAfter time.Time
ClosedBefore time.Time
SortBy string
SortDesc bool
Limit int
IDs []string
}
ListIssuesOptions contains filter options for listing issues
type ListNotesOptions ¶ added in v0.33.0
type ListNotesOptions struct {
Pinned *bool // nil = don't filter, true = only pinned, false = only unpinned
Archived *bool // nil = don't filter, true = only archived, false = only unarchived
IncludeDeleted bool // include soft-deleted notes
Search string // search title/content
Limit int // max results (default 50 if 0)
}
ListNotesOptions contains filter options for listing notes
type RespaceResult ¶ added in v0.30.0
RespaceResult records a position change made during a respace operation.
type SearchResult ¶ added in v0.4.9
type SearchResult struct {
Issue models.Issue
Score int // Higher = better match (0-100)
MatchField string // Primary field that matched: 'id', 'title', 'description', 'labels'
}
SearchResult holds an issue with relevance scoring for ranked search
type SecurityEvent ¶ added in v0.5.0
type SecurityEvent struct {
Timestamp time.Time `json:"ts"`
IssueID string `json:"issue_id"`
SessionID string `json:"session_id"`
AgentType string `json:"agent_type,omitempty"`
Reason string `json:"reason"`
}
SecurityEvent represents a security-relevant action (like a self-close exception)
func ReadSecurityEvents ¶ added in v0.5.0
func ReadSecurityEvents(baseDir string) ([]SecurityEvent, error)
ReadSecurityEvents reads all security events from the file
type SessionRow ¶ added in v0.27.0
type SessionRow struct {
ID string
Name string
Branch string
AgentType string
AgentPID int
ContextID string
PreviousSessionID string
StartedAt time.Time
LastActivity time.Time
}
SessionRow represents a session record in the database
type SyncConflict ¶ added in v0.30.0
type SyncConflict struct {
ID int64
EntityType string
EntityID string
ServerSeq int64
LocalData string
RemoteData string
OverwrittenAt time.Time
}
SyncConflict represents a row from the sync_conflicts table.
type SyncHistoryEntry ¶ added in v0.30.0
type SyncHistoryEntry struct {
ID int64
Direction string // "push" or "pull"
ActionType string // "create", "update", "delete"
EntityType string // "issues", "logs", etc.
EntityID string
ServerSeq int64
DeviceID string
Timestamp time.Time
}
SyncHistoryEntry represents a row from the sync_history table.