2026-05-02 10:37:38 -05:00
|
|
|
package stage
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
|
2026-05-02 11:16:27 -05:00
|
|
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notify"
|
2026-05-02 10:37:38 -05:00
|
|
|
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-02 11:05:28 -05:00
|
|
|
const placeholderMessage = "placeholder stage: no real work executed"
|
|
|
|
|
|
|
|
|
|
type placeholderStage struct {
|
|
|
|
|
name string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s placeholderStage) Name() string { return s.name }
|
|
|
|
|
|
2026-05-02 11:16:27 -05:00
|
|
|
func (s placeholderStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*StageResult, error) {
|
|
|
|
|
result := &StageResult{
|
2026-05-02 11:05:28 -05:00
|
|
|
Metadata: map[string]any{
|
|
|
|
|
"placeholder": true,
|
|
|
|
|
"stage": s.name,
|
|
|
|
|
"message": placeholderMessage,
|
|
|
|
|
},
|
2026-05-02 11:16:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if env == nil || env.Config == nil || env.ArtifactStore == nil {
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sessionID := m.SessionID
|
|
|
|
|
if sessionID == "" && env.Config.Session != nil {
|
|
|
|
|
sessionID = env.Config.Session.SessionID
|
|
|
|
|
}
|
|
|
|
|
if sessionID == "" {
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch s.name {
|
|
|
|
|
case "notify":
|
|
|
|
|
if env.Notifier != nil {
|
|
|
|
|
req := notify.SendRequest{
|
|
|
|
|
Subject: "narratio placeholder run complete",
|
|
|
|
|
Body: "placeholder stage execution finished",
|
|
|
|
|
Metadata: map[string]string{
|
|
|
|
|
"session_id": sessionID,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
_, err := env.Notifier.Send(ctx, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("placeholder notify adapter call failed: %w", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result, nil
|
2026-05-02 11:05:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// All returns the canonical ordered stage list for full pipeline execution.
|
|
|
|
|
func All() []Stage {
|
|
|
|
|
return []Stage{
|
2026-05-02 11:26:43 -05:00
|
|
|
prepareStage{},
|
2026-05-03 15:42:44 -05:00
|
|
|
transcribeStage{},
|
2026-05-03 22:17:17 -05:00
|
|
|
mergeStage{},
|
2026-05-04 08:05:27 -05:00
|
|
|
polishStage{},
|
2026-05-10 21:26:53 +00:00
|
|
|
normalizeStage{},
|
2026-05-08 17:08:44 +00:00
|
|
|
trimStage{},
|
2026-05-25 00:40:06 +00:00
|
|
|
renderStage{},
|
2026-08-29 18:00:22 +00:00
|
|
|
extractStage{},
|
2026-05-06 21:26:54 +00:00
|
|
|
analyzeStage{},
|
2026-05-23 13:39:15 +00:00
|
|
|
publishStage{},
|
2026-05-02 11:05:28 -05:00
|
|
|
placeholderStage{name: "notify"},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Select returns one stage by exact name from the canonical stage set.
|
|
|
|
|
func Select(name string) (Stage, error) {
|
|
|
|
|
for _, s := range All() {
|
|
|
|
|
if s.Name() == name {
|
|
|
|
|
return s, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil, fmt.Errorf("unknown stage %q", name)
|
2026-05-02 10:37:38 -05:00
|
|
|
}
|