package port

import (
	"context"
	"time"

	"github.com/orchard9/rdev/internal/domain"
)

// BuildEventStore defines persistence operations for build events.
// Used for SSE reconnection replay when in-memory buffer is exhausted.
type BuildEventStore interface {
	// Record stores a build event for later replay.
	Record(ctx context.Context, event *domain.BuildEvent) error

	// ListByTask retrieves events for a task, optionally after a sequence number.
	// If afterSequence > 0, only events with sequence > afterSequence are returned.
	// Results are ordered by sequence ascending.
	ListByTask(ctx context.Context, taskID string, afterSequence int64) ([]*domain.BuildEvent, error)

	// Cleanup removes events older than the specified age.
	// Returns the number of events deleted.
	Cleanup(ctx context.Context, olderThan time.Duration) (int64, error)
}
