Files
narratio/internal/stage/placeholders.go

94 lines
2.2 KiB
Go

package stage
import (
"context"
"fmt"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notify"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
)
const placeholderMessage = "placeholder stage: no real work executed"
type placeholderStage struct {
name string
}
func (s placeholderStage) Name() string { return s.name }
func (s placeholderStage) Declares() IODecl {
return IODecl{
Inputs: []artifacts.Ref{{Kind: "artifact", Category: "input", RelativePath: s.name + ".input.placeholder"}},
Outputs: []artifacts.Ref{{Kind: "artifact", Category: "output", RelativePath: s.name + ".output.placeholder"}},
}
}
func (s placeholderStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*StageResult, error) {
result := &StageResult{
Metadata: map[string]any{
"placeholder": true,
"stage": s.name,
"message": placeholderMessage,
},
}
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
}
// All returns the canonical ordered stage list for full pipeline execution.
func All() []Stage {
return []Stage{
prepareStage{},
transcribeStage{},
mergeStage{},
polishStage{},
normalizeStage{},
trimStage{},
extractStage{},
renderStage{},
analyzeStage{},
publishStage{},
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)
}