feat(usecase): implement ProcessNewVideo core path
CI / Lint / Test / Vet (push) Successful in 3s
CI / Build & Import (push) Failing after 1s
CI / Mirror to GitHub (push) Has been skipped

Resolve transcript -> summarize -> deliver, or skip when no usable
transcript. Sinks fail independently: a failing sink does not abort the
others and successful deliveries are kept; per-sink errors are returned
joined. Makes the two scaffolded acceptance scenarios GREEN.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 16:24:18 +02:00
co-authored by Claude Opus 4.8
parent a234be7817
commit b4aa096ac3
+26 -1
View File
@@ -11,6 +11,7 @@ package usecase
import ( import (
"context" "context"
"errors" "errors"
"fmt"
"gitea.d-ma.be/mathias/tapir/internal/domain" "gitea.d-ma.be/mathias/tapir/internal/domain"
"gitea.d-ma.be/mathias/tapir/internal/ports" "gitea.d-ma.be/mathias/tapir/internal/ports"
@@ -43,5 +44,29 @@ type ProcessResult struct {
// resolve transcript -> (summarize -> deliver) | skip. // resolve transcript -> (summarize -> deliver) | skip.
// See docs/use-cases/summarize_new_video.feature. // See docs/use-cases/summarize_new_video.feature.
func (e *Engine) ProcessNewVideo(ctx context.Context, v domain.Video) (ProcessResult, error) { func (e *Engine) ProcessNewVideo(ctx context.Context, v domain.Video) (ProcessResult, error) {
return ProcessResult{}, ErrNotImplemented t, err := e.Source.FetchTranscript(ctx, v)
if err != nil {
return ProcessResult{Video: v}, fmt.Errorf("fetch transcript: %w", err)
}
if !t.HasText() {
// No usable transcript: record the skip, produce no summary, deliver nothing
// (captions-first, ADR-007; the watcher uses this to avoid reprocessing).
return ProcessResult{Video: v, Skipped: true, Reason: "no transcript"}, nil
}
sum, err := e.AI.Summarize(ctx, v, t)
if err != nil {
return ProcessResult{Video: v}, fmt.Errorf("summarize: %w", err)
}
// Sinks fail independently: a failing sink must not abort the others, and
// successful deliveries are not dropped. Collect every error, return them joined.
var errs []error
for _, sink := range e.Sinks {
if err := sink.Deliver(ctx, sum); err != nil {
errs = append(errs, fmt.Errorf("deliver to %s: %w", sink.Name(), err))
}
}
return ProcessResult{Video: v, Summary: &sum}, errors.Join(errs...)
} }