Files
pipelines/internal/pipeline/overrides_test.go
T
alan fc7dbb0ac0 Remove ntfy: notifications go only through the app notification stream
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat
tool notify, auto-switch and schedule notices), the chat push outbox (its
table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*.
The app_notifications stream, subscribe/clear and kinds are unchanged.
Notification settings keep run_finished/chat_needs_you/chat_reply_finished;
ntfy_enabled is accepted and ignored and its stored row is never read.

Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to
the Pipelines apps — use the stage notify hook". The notify hook remains.

Installer: no ntfy build, accounts, config or supervisor child; manifest
gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an
old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log,
with a note in logs/install.log); uninstall cleans leftovers.

App: ntfy settings section replaced by "Notification events"; texts updated.
Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli,
author skill references updated; security review M1 marked resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:24:24 +00:00

106 lines
3.8 KiB
Go

package pipeline
import (
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
func overrideGraph() protocol.Graph {
return protocol.Graph{Stages: []protocol.Stage{
{Key: "plan", Type: "model", Configs: map[string]string{"provider": "pinned", "model": "pinned-model"}},
{Key: "note", Type: "human", Configs: map[string]string{}},
{Key: "review", Type: "model", Configs: map[string]string{"provider": "pinned2", "model": "pinned2-model"}},
}}
}
// TestEffectiveModelsPrecedence proves the one precedence rule: a per-stage
// override beats the whole-run override, which beats the model pinned in the
// pipeline version, and with no override the pinned pair is returned unchanged.
func TestEffectiveModelsPrecedence(t *testing.T) {
graph := overrideGraph()
cases := []struct {
name string
model string
stageModels map[string]string
want map[string]ModelOverride
}{
{
name: "no override keeps the pinned pair",
want: map[string]ModelOverride{
"plan": {Provider: "pinned", Model: "pinned-model"},
"review": {Provider: "pinned2", Model: "pinned2-model"},
},
},
{
name: "whole-run beats the pinned pair",
model: "acme/whole",
want: map[string]ModelOverride{
"plan": {Provider: "acme", Model: "whole"},
"review": {Provider: "acme", Model: "whole"},
},
},
{
name: "per-stage beats whole-run and leaves the other pinned",
model: "acme/whole",
stageModels: map[string]string{"plan": "acme/stage"},
want: map[string]ModelOverride{
"plan": {Provider: "acme", Model: "stage"},
"review": {Provider: "acme", Model: "whole"},
},
},
{
name: "per-stage alone leaves the other pinned",
stageModels: map[string]string{"plan": "acme/stage"},
want: map[string]ModelOverride{
"plan": {Provider: "acme", Model: "stage"},
"review": {Provider: "pinned2", Model: "pinned2-model"},
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := EffectiveModels(graph, tc.model, tc.stageModels)
if err != nil {
t.Fatal(err)
}
if len(got) != len(tc.want) {
t.Fatalf("effective = %+v, want %+v", got, tc.want)
}
for key, want := range tc.want {
if got[key] != want {
t.Fatalf("stage %s = %+v, want %+v", key, got[key], want)
}
}
})
}
}
// TestEffectiveModelsRejectsBadInput proves an unknown stage key fails naming the
// valid keys, a malformed provider/model fails, and a per-stage key for a
// non-model stage is refused as one that can never honour it.
func TestEffectiveModelsRejectsBadInput(t *testing.T) {
graph := overrideGraph()
if _, err := EffectiveModels(graph, "", map[string]string{"nope": "acme/x"}); err == nil || !strings.Contains(err.Error(), "unknown stage key") || !strings.Contains(err.Error(), "note, plan, review") {
t.Fatalf("unknown key error = %v, want the valid keys named", err)
}
for _, value := range []string{"not-a-pair", "/model", "provider/", "bad provider/model", "provider/bad model"} {
if _, err := EffectiveModels(graph, value, nil); err == nil {
t.Fatalf("whole-run value %q was accepted", value)
}
if _, err := EffectiveModels(graph, "", map[string]string{"plan": value}); err == nil {
t.Fatalf("per-stage value %q was accepted", value)
}
}
if _, err := EffectiveModels(graph, "", map[string]string{"note": "acme/x"}); err == nil || !strings.Contains(err.Error(), "cannot honour") {
t.Fatalf("non-model stage override error = %v, want a cannot-honour refusal", err)
}
// A whole-run override on a graph with no model stage is accepted and inert.
inert := protocol.Graph{Stages: []protocol.Stage{{Key: "note", Type: "human", Configs: map[string]string{}}}}
got, err := EffectiveModels(inert, "acme/whole", nil)
if err != nil || len(got) != 0 {
t.Fatalf("whole-run override on a no-model graph = %+v, %v; want inert", got, err)
}
}