54 lines
2.1 KiB
Go
54 lines
2.1 KiB
Go
// Package review is the daemon's HTTP-facing code-review service boundary. The
|
|
// core orchestration lives in internal/review; this layer is the thin contract
|
|
// the API controller depends on and delegates to the engine, so the same engine
|
|
// can also back a future in-process CLI trigger.
|
|
package review
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/aoagents/agent-orchestrator/backend/internal/domain"
|
|
reviewcore "github.com/aoagents/agent-orchestrator/backend/internal/review"
|
|
)
|
|
|
|
// ErrInvalid and ErrNotFound re-export the engine sentinels so the HTTP
|
|
// controller maps service failures to 422/404 without importing the core.
|
|
var (
|
|
ErrInvalid = reviewcore.ErrInvalid
|
|
ErrNotFound = reviewcore.ErrNotFound
|
|
)
|
|
|
|
// Manager is the reviews surface the HTTP controller depends on.
|
|
type Manager interface {
|
|
Trigger(ctx context.Context, workerID domain.SessionID) (reviewcore.TriggerResult, error)
|
|
Submit(ctx context.Context, workerID domain.SessionID, runID string, verdict domain.ReviewVerdict, body string) (domain.ReviewRun, error)
|
|
List(ctx context.Context, workerID domain.SessionID) (reviewcore.SessionReviews, error)
|
|
}
|
|
|
|
// Service is the API-facing review service. It delegates to the core engine.
|
|
type Service struct {
|
|
engine *reviewcore.Engine
|
|
}
|
|
|
|
var _ Manager = (*Service)(nil)
|
|
|
|
// New wraps a core review engine as the API-facing service.
|
|
func New(engine *reviewcore.Engine) *Service {
|
|
return &Service{engine: engine}
|
|
}
|
|
|
|
// Trigger starts (or reuses) a review pass for a worker's PR.
|
|
func (s *Service) Trigger(ctx context.Context, workerID domain.SessionID) (reviewcore.TriggerResult, error) {
|
|
return s.engine.Trigger(ctx, workerID)
|
|
}
|
|
|
|
// Submit records a reviewer's result for a specific worker review pass.
|
|
func (s *Service) Submit(ctx context.Context, workerID domain.SessionID, runID string, verdict domain.ReviewVerdict, body string) (domain.ReviewRun, error) {
|
|
return s.engine.Submit(ctx, workerID, runID, verdict, body)
|
|
}
|
|
|
|
// List returns a worker's review state.
|
|
func (s *Service) List(ctx context.Context, workerID domain.SessionID) (reviewcore.SessionReviews, error) {
|
|
return s.engine.List(ctx, workerID)
|
|
}
|