rdev/internal/port/session_repository.go
jordan 3dbde72966
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat: add claude_id tracking and session improvements for interactive dev
- Add claude_id field to sessions (migration 026) for tracking Claude
  process IDs across pod restarts
- Extend session repository with UpdateClaudeID and session lookup methods
- Improve kubernetes executor with better error handling and exec streaming
- Add claudebox client/server improvements for session lifecycle
- Expand sessions handler with exec streaming endpoint
- Add comprehensive tests for sessions and kubernetes executor

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 00:20:32 -07:00

37 lines
1.5 KiB
Go

// Package port defines interfaces (ports) for external dependencies.
package port
import (
"context"
"github.com/orchard9/rdev/internal/domain"
)
// SessionRepository manages session persistence.
type SessionRepository interface {
// Create stores a new session record.
Create(ctx context.Context, session *domain.Session) error
// Get retrieves a session by ID.
Get(ctx context.Context, id domain.SessionID) (*domain.Session, error)
// GetActiveByProject retrieves the active session for a project (at most one).
GetActiveByProject(ctx context.Context, projectID domain.ProjectID) (*domain.Session, error)
// ListByProject returns all sessions for a project, ordered by created_at DESC.
ListByProject(ctx context.Context, projectID domain.ProjectID) ([]*domain.Session, error)
// SetEnded marks a session as ended with a timestamp.
SetEnded(ctx context.Context, id domain.SessionID) error
// TouchActivity updates the last_activity_at timestamp for an active session.
TouchActivity(ctx context.Context, id domain.SessionID) error
// CleanupExpired marks expired sessions and returns them for preview teardown.
CleanupExpired(ctx context.Context) ([]*domain.Session, error)
// SetClaudeSessionID stores the Claude Code session ID and conversation record ID on a session.
// Used after the first successful claude exec to enable --resume for subsequent turns.
SetClaudeSessionID(ctx context.Context, id domain.SessionID, claudeSessionID, conversationRecordID string) error
}