rdev/internal/port/session_repository.go
jordan 7249575dea
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat(sessions): add command execution endpoint and activity tracking
- Add POST /sessions/:id/exec endpoint for executing commands in sessions
- Add session activity tracking (last_activity_at timestamp)
- Add database migration 024 for session activity column
- Add comprehensive tests for session handlers and service layer
- Add wildcard TLS certificate for preview.threesix.ai subdomain
- Add infrastructure mocks for testing preview service
- Refactor preview cleanup logic to remove unused methods
- Add AIOS core documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-13 08:41:05 -07:00

33 lines
1.2 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)
}