textmachine/backend/internal/config/example_test.go

48 lines
2.1 KiB
Go

package config
import (
"os"
"testing"
)
// example_test.go pins that the shipped example project (example/book.yaml) is RUNNABLE through the
// pair prompt seam (D39 layer 2 / D39.2 T3; pack-15 form: resolution by prompts/<pair>/<role>.md). Reframed to the prod pair zh→ru, LoadBook +
// LoadPipeline resolve, every stage's prompt resolves for the book's pair and exists on disk, and a
// ja-ru pair still FAILS LOUD — the seam the example's commented-out ja block documents. The old ja
// framing regressed to a fail-loud after the pair seam landed (D39.2-open №4); this is the guard that
// the reframe fixed it without silently smuggling a ja book through the zh-ru conventions.
func TestExampleProjectIsRunnableZhRu(t *testing.T) {
book, err := LoadBook("../../example/book.yaml")
if err != nil {
t.Fatalf("example book must load (source_file etc. must exist): %v", err)
}
if book.LangPair() != "zh-ru" {
t.Fatalf("example must be reframed to the prod pair zh→ru, got LangPair() = %q", book.LangPair())
}
models, err := LoadModels(book.ModelsFile)
if err != nil {
t.Fatalf("example models must load: %v", err)
}
pipe, err := LoadPipeline(book.Pipeline, models, "zh-ru")
if err != nil {
t.Fatalf("example pipeline must load: %v", err)
}
if len(pipe.Stages) == 0 {
t.Fatal("example pipeline has no stages")
}
// zh-ru: every stage resolved a prompt for the book's pair AND the resolved file exists (no
// fail-loud, no dangling path) — the exact end-to-end the pair seam broke for the old ja framing.
for _, st := range pipe.Stages {
if st.PromptPath == "" {
t.Fatalf("stage %q: zh-ru prompt must resolve", st.Name)
}
if _, err := os.Stat(st.PromptPath); err != nil {
t.Fatalf("stage %q: resolved prompt %q must exist on disk: %v", st.Name, st.PromptPath, err)
}
}
// ja-ru: the seam still bites a pair the repo does not carry (what the commented-out ja block in
// example/book.yaml documents) — the LOAD fails, naming the prompt path it looked for.
if _, err := LoadPipeline(book.Pipeline, models, "ja-ru"); err == nil {
t.Fatal("a ja-ru pair must fail loud through the example pipeline (the pair seam)")
}
}