Documentation
¶
Index ¶
- Constants
- func InferTaskKey(branch string) string
- type Manager
- func (m *Manager) ActiveTaskThreads(ctx context.Context) ([]TaskThread, error)
- func (m *Manager) CleanupOldEvents(ctx context.Context, retention time.Duration) (int, error)
- func (m *Manager) EndSession(ctx context.Context, sessionID string) error
- func (m *Manager) EndStaleSessions(ctx context.Context, maxAge time.Duration) (int, error)
- func (m *Manager) GetActiveSession(ctx context.Context, sourceSessionID string) (*Session, error)
- func (m *Manager) GetTaskThread(ctx context.Context, key string) (*TaskThread, error)
- func (m *Manager) GetWorkingSet(ctx context.Context, sessionID string) (*WorkingSet, error)
- func (m *Manager) RecordActivity(ctx context.Context, sessionID string) error
- func (m *Manager) SessionStats(ctx context.Context) (total int, active int, err error)
- func (m *Manager) SetTaskStatus(ctx context.Context, key, status string) error
- func (m *Manager) StartSession(ctx context.Context, sourceTool, sourceSessionID, projectID, directory string) (string, error)
- func (m *Manager) UpdateWorkingSet(ctx context.Context, sessionID string, delta WorkingSetDelta) (*WorkingSet, error)
- func (m *Manager) UpsertTaskThread(ctx context.Context, key string, delta TaskThreadDelta) (*TaskThread, error)
- type Session
- type TaskThread
- type TaskThreadDelta
- type WorkingSet
- type WorkingSetDelta
Constants ¶
const ( TaskStatusActive = "active" TaskStatusPaused = "paused" TaskStatusDone = "done" TaskStatusCancelled = "cancelled" )
Task thread statuses. Lifecycle is driven by explicit commands or automation (branch inference, done-on-merge later) — never by interactive prompts.
Variables ¶
This section is empty.
Functions ¶
func InferTaskKey ¶ added in v0.8.3
InferTaskKey extracts a normalized (uppercase) ticket key from a branch name like "feature/PROJ-123-fix-login". Returns "" when none is present.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) ActiveTaskThreads ¶ added in v0.8.3
func (m *Manager) ActiveTaskThreads(ctx context.Context) ([]TaskThread, error)
ActiveTaskThreads lists threads in active status, most recently touched first.
func (*Manager) CleanupOldEvents ¶ added in v0.4.6
CleanupOldEvents deletes session_events rows older than retention. Returns the number of rows removed. Intended to be called on a long interval (daily) from the serve goroutine — session_events grows fast under PostToolUse pressure (one row per tool call) and accumulates stale rows quickly without a TTL.
func (*Manager) EndSession ¶
EndSession sets ended_at on the session.
func (*Manager) EndStaleSessions ¶
EndStaleSessions ends sessions with no activity for longer than maxAge. Returns the count of sessions closed.
func (*Manager) GetActiveSession ¶
GetActiveSession returns the active (not ended) session for sourceSessionID, or nil.
func (*Manager) GetTaskThread ¶ added in v0.8.3
GetTaskThread returns the thread for key, or nil when it does not exist.
func (*Manager) GetWorkingSet ¶ added in v0.7.2
GetWorkingSet returns the working set for a session, or nil when none exists.
func (*Manager) RecordActivity ¶
RecordActivity bumps last_activity_at and increments message_count.
func (*Manager) SessionStats ¶
SessionStats returns total and active session counts.
func (*Manager) SetTaskStatus ¶ added in v0.8.3
SetTaskStatus moves a thread to status (active|paused|done|cancelled).
func (*Manager) StartSession ¶
func (m *Manager) StartSession(ctx context.Context, sourceTool, sourceSessionID, projectID, directory string) (string, error)
StartSession creates a new live session or resumes an existing active one matching sourceSessionID.
func (*Manager) UpdateWorkingSet ¶ added in v0.7.2
func (m *Manager) UpdateWorkingSet(ctx context.Context, sessionID string, delta WorkingSetDelta) (*WorkingSet, error)
UpdateWorkingSet merges delta into the session's working set (creating it on first call) and returns the resulting set. A topic shift (changed TopicKey or ProjectID) resets the prior focus before applying the delta.
func (*Manager) UpsertTaskThread ¶ added in v0.8.3
func (m *Manager) UpsertTaskThread(ctx context.Context, key string, delta TaskThreadDelta) (*TaskThread, error)
UpsertTaskThread merges delta into the thread, creating it (status active) on first touch. Resuming work on a paused thread reactivates it; done and cancelled threads are terminal for automation (only an explicit SetTaskStatus reopens them).
type Session ¶
type Session struct {
ID string `json:"id"`
ProjectID *string `json:"project_id,omitempty"`
Source string `json:"source"`
SourceSessionID string `json:"source_session_id,omitempty"`
Title string `json:"title,omitempty"`
Directory string `json:"directory,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
LastActivityAt *time.Time `json:"last_activity_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
MessageCount int `json:"message_count"`
SourceTool string `json:"source_tool,omitempty"`
Metadata any `json:"metadata,omitempty"`
}
type TaskThread ¶ added in v0.8.3
type TaskThread struct {
TaskKey string
ExternalRef string
ProjectIDs []string
Journal []string
SessionIDs []string
Status string
CreatedAt time.Time
UpdatedAt time.Time
}
TaskThread is a first-class, cross-project unit of work: one Jira ticket / Trello card / branch-named task that may touch several repositories. It references — never duplicates — per-project data: memories keep their own project_id; the thread just ties the strands together.
type TaskThreadDelta ¶ added in v0.8.3
type TaskThreadDelta struct {
ProjectID string
SessionID string
JournalNote string
ExternalRef string
}
TaskThreadDelta is a partial update merged into a thread (created on first touch). Empty fields are ignored.
type WorkingSet ¶ added in v0.7.2
type WorkingSet struct {
SessionID string `json:"session_id"`
ProjectID string `json:"project_id,omitempty"`
Files []string `json:"files,omitempty"`
Symbols []string `json:"symbols,omitempty"`
Entities []string `json:"entities,omitempty"`
Commands []string `json:"commands,omitempty"`
Tests []string `json:"tests,omitempty"`
Errors []string `json:"errors,omitempty"`
MemoryIDs []string `json:"memory_ids,omitempty"`
ArtifactIDs []string `json:"artifact_ids,omitempty"`
TopicKey string `json:"topic_key,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
WorkingSet is the per-session record of what is actively being worked on: touched files, referenced symbols/entities, run commands/tests, observed errors, and the memory/artifact ids surfaced during the session. Retrieval uses the files/symbols/entities to boost overlapping memories.
func (*WorkingSet) Empty ¶ added in v0.7.2
func (w *WorkingSet) Empty() bool
Empty reports whether the working set carries no focus signals.
type WorkingSetDelta ¶ added in v0.7.2
type WorkingSetDelta struct {
ProjectID string
Files []string
Symbols []string
Entities []string
Commands []string
Tests []string
Errors []string
MemoryIDs []string
ArtifactIDs []string
TopicKey string
}
WorkingSetDelta is an incremental update merged into the stored set. Empty slices are ignored. When TopicKey is set and differs from the stored key (or ProjectID changes), the existing set is reset before the delta is applied — this is the topic-shift reset that prevents a stale focus from biasing a new line of work.