Verify shared glossary selection across CLI workflows
This commit is contained in:
@@ -195,6 +195,8 @@ custom sandbox is needed to establish removal of the discovery path.
|
|||||||
|
|
||||||
## Stage 5: Verify Selection, Preflight, and CLI Integration
|
## Stage 5: Verify Selection, Preflight, and CLI Integration
|
||||||
|
|
||||||
|
**Completed.** Maintained example conversion and its integrated checks follow in Stage 6.
|
||||||
|
|
||||||
**Work**
|
**Work**
|
||||||
|
|
||||||
1. Keep `glossary.Select`, protected vocabulary, root/stage selection resolution,
|
1. Keep `glossary.Select`, protected vocabulary, root/stage selection resolution,
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func buildApplication(extra ...commandkit.Declaration) (*commandkit.App, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buildApplicationWithClient(client *http.Client, extra ...commandkit.Declaration) (*commandkit.App, error) {
|
func buildApplicationWithClient(client *http.Client, extra ...commandkit.Declaration) (*commandkit.App, error) {
|
||||||
selector := commandkit.RepeatFlag(commandkit.FlagMeta{Name: "glossary-file", Usage: "Runtime glossary file (repeatable)."}, nil, func(s string) (string, error) { return s, nil }, func(in *acquisitionInput, value commandkit.Supplied[[]string]) { in.GlossaryFiles = value.Value })
|
selector := commandkit.RepeatFlag(commandkit.FlagMeta{Name: "glossary-file", Usage: "Shared glossary YAML or JSON file (repeatable)."}, nil, func(s string) (string, error) { return s, nil }, func(in *acquisitionInput, value commandkit.Supplied[[]string]) { in.GlossaryFiles = value.Value })
|
||||||
appScope := ckconfig.FromConfigKit("app", "Audita application settings.", loadApplication)
|
appScope := ckconfig.FromConfigKit("app", "Audita application settings.", loadApplication)
|
||||||
appScope.Features.Overrides = true
|
appScope.Features.Overrides = true
|
||||||
appScope = shareComparisonGlossaries(withBootstrapContext(appScope))
|
appScope = shareComparisonGlossaries(withBootstrapContext(appScope))
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ func TestPromptEngineCacheIncludesRuntimeGlossaryInput(t *testing.T) {
|
|||||||
main := filepath.Join(dir, "main.yml")
|
main := filepath.Join(dir, "main.yml")
|
||||||
first := filepath.Join(dir, "first.yml")
|
first := filepath.Join(dir, "first.yml")
|
||||||
second := filepath.Join(dir, "second.yml")
|
second := filepath.Join(dir, "second.yml")
|
||||||
for path, contents := range map[string]string{main: "version: 3\n", first: "one: {entries: []}\n", second: "two: {entries: []}\n"} {
|
for path, contents := range map[string]string{main: "version: 3\n", first: "schema_version: maximumdirect.glossary.v1\ncollections: {one: {entries: []}}\n", second: "schema_version: maximumdirect.glossary.v1\ncollections: {two: {entries: []}}\n"} {
|
||||||
if err := os.WriteFile(path, []byte(contents), 0600); err != nil {
|
if err := os.WriteFile(path, []byte(contents), 0600); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ func TestRuntimeGlossaryExampleWorkflow(t *testing.T) {
|
|||||||
args = append([]string{"process"}, common...)
|
args = append([]string{"process"}, common...)
|
||||||
args = append(args, "--output", filepath.Join(dir, "output.json"), filepath.Join(dir, "transcript.json"))
|
args = append(args, "--output", filepath.Join(dir, "output.json"), filepath.Join(dir, "transcript.json"))
|
||||||
result = app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &stderr})
|
result = app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &stderr})
|
||||||
if result.Status != 0 || !strings.Contains(seen, "Mira Chen") || !strings.Contains(seen, "North Observatory") || !strings.Contains(seen, "speaker's preferred spelling") || !strings.Contains(seen, "Preserve established place names") {
|
if result.Status != 0 || !strings.Contains(seen, "Mira Chen") || !strings.Contains(seen, "North Observatory") || !strings.Contains(seen, "Preserve established place names") {
|
||||||
t.Fatalf("processing %d seen=%s stderr=%s", result.Status, seen, stderr.String())
|
t.Fatalf("processing %d seen=%s stderr=%s", result.Status, seen, stderr.String())
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(filepath.Join(dir, "output.json")); err != nil {
|
if _, err := os.Stat(filepath.Join(dir, "output.json")); err != nil {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func TestPreflightBindingsAndRunAlias(t *testing.T) {
|
|||||||
for name, contents := range map[string]string{
|
for name, contents := range map[string]string{
|
||||||
"config.yml": "version: 3\npipeline: {stages: []}\nreporting: {enabled: false}\n",
|
"config.yml": "version: 3\npipeline: {stages: []}\nreporting: {enabled: false}\n",
|
||||||
"transcript.json": `[{"speaker":"Alice","start":0,"end":1,"text":"hello"}]`,
|
"transcript.json": `[{"speaker":"Alice","start":0,"end":1,"text":"hello"}]`,
|
||||||
"glossary.yml": "party: {entries: [{id: alice, name: Alice, category: person}]}\n",
|
"glossary.yml": "schema_version: maximumdirect.glossary.v1\ncollections: {party: {entries: [{id: alice, name: Alice, category: person}]}}\n",
|
||||||
"overlays/local.yml": "context: {description: Local example}\n",
|
"overlays/local.yml": "context: {description: Local example}\n",
|
||||||
} {
|
} {
|
||||||
path := filepath.Join(dir, name)
|
path := filepath.Join(dir, name)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type processInput struct {
|
|||||||
func processingFlags() []commandkit.Flag[processInput] {
|
func processingFlags() []commandkit.Flag[processInput] {
|
||||||
stringValue := func(s string) (string, error) { return s, nil }
|
stringValue := func(s string) (string, error) { return s, nil }
|
||||||
flags := []commandkit.Flag[processInput]{
|
flags := []commandkit.Flag[processInput]{
|
||||||
commandkit.RepeatFlag(commandkit.FlagMeta{Name: "glossary-file", Usage: "Runtime glossary file (repeatable)."}, nil, stringValue, func(in *processInput, v commandkit.Supplied[[]string]) { in.GlossaryFiles = v.Value }),
|
commandkit.RepeatFlag(commandkit.FlagMeta{Name: "glossary-file", Usage: "Shared glossary YAML or JSON file (repeatable)."}, nil, stringValue, func(in *processInput, v commandkit.Supplied[[]string]) { in.GlossaryFiles = v.Value }),
|
||||||
commandkit.ValueFlag(commandkit.FlagMeta{Name: "config", Usage: "Application configuration file."}, (*string)(nil), stringValue, func(in *processInput, v commandkit.Supplied[string]) { in.Config = v }),
|
commandkit.ValueFlag(commandkit.FlagMeta{Name: "config", Usage: "Application configuration file."}, (*string)(nil), stringValue, func(in *processInput, v commandkit.Supplied[string]) { in.Config = v }),
|
||||||
commandkit.ValueFlag(commandkit.FlagMeta{Name: "overlay", Usage: "Configuration overlay."}, (*string)(nil), stringValue, func(in *processInput, v commandkit.Supplied[string]) { in.Overlay = v }),
|
commandkit.ValueFlag(commandkit.FlagMeta{Name: "overlay", Usage: "Configuration overlay."}, (*string)(nil), stringValue, func(in *processInput, v commandkit.Supplied[string]) { in.Overlay = v }),
|
||||||
commandkit.ValueFlag(commandkit.FlagMeta{Name: "output", Usage: "Transcript output file."}, (*string)(nil), stringValue, func(in *processInput, v commandkit.Supplied[string]) { in.Output = v }),
|
commandkit.ValueFlag(commandkit.FlagMeta{Name: "output", Usage: "Transcript output file."}, (*string)(nil), stringValue, func(in *processInput, v commandkit.Supplied[string]) { in.Output = v }),
|
||||||
|
|||||||
@@ -72,11 +72,6 @@ func TestProcessingUsesPerEntryProfilesInOrder(t *testing.T) {
|
|||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
files := map[string]string{
|
files := map[string]string{
|
||||||
"config.yml": `version: 3
|
"config.yml": `version: 3
|
||||||
glossary_collections:
|
|
||||||
party:
|
|
||||||
entries: [{id: alice, name: Alice, category: person}]
|
|
||||||
spells:
|
|
||||||
entries: [{id: shield, name: Shield, category: spell}]
|
|
||||||
protected_terms: [party, spells]
|
protected_terms: [party, spells]
|
||||||
llm: {validation_profile: review}
|
llm: {validation_profile: review}
|
||||||
pipeline:
|
pipeline:
|
||||||
@@ -92,6 +87,15 @@ pipeline:
|
|||||||
- module: grammar
|
- module: grammar
|
||||||
glossaries: [party, spells]
|
glossaries: [party, spells]
|
||||||
llm: {proposal_profile: three}
|
llm: {proposal_profile: three}
|
||||||
|
`,
|
||||||
|
"shared.yml": `schema_version: maximumdirect.glossary.v1
|
||||||
|
collections:
|
||||||
|
party:
|
||||||
|
entries: [{id: alice, name: Alice, category: person}]
|
||||||
|
spells:
|
||||||
|
entries: [{id: shield, name: Shield, category: spell}]
|
||||||
|
unused:
|
||||||
|
entries: [{id: unused, name: Unselected, category: topic}]
|
||||||
`,
|
`,
|
||||||
"prompts.yml": fmt.Sprintf("profiles:\n - {id: one, endpoint: %q, model: model-one, api_key_required: false}\n - {id: two, endpoint: %q, model: model-two, api_key_required: false}\n - {id: three, endpoint: %q, model: model-three, api_key_required: false}\n - {id: review, endpoint: %q, model: review, api_key_required: false}\n", "https://example.invalid/v1", "https://example.invalid/v1", "https://example.invalid/v1", "https://example.invalid/v1"),
|
"prompts.yml": fmt.Sprintf("profiles:\n - {id: one, endpoint: %q, model: model-one, api_key_required: false}\n - {id: two, endpoint: %q, model: model-two, api_key_required: false}\n - {id: three, endpoint: %q, model: model-three, api_key_required: false}\n - {id: review, endpoint: %q, model: review, api_key_required: false}\n", "https://example.invalid/v1", "https://example.invalid/v1", "https://example.invalid/v1", "https://example.invalid/v1"),
|
||||||
"transcript.json": `[{"speaker":"Alice","start":0,"end":1,"text":"Alyce casts Sheeld."}]`,
|
"transcript.json": `[{"speaker":"Alice","start":0,"end":1,"text":"Alyce casts Sheeld."}]`,
|
||||||
@@ -101,7 +105,7 @@ pipeline:
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{GlossaryFiles: []string{filepath.Join(dir, "shared.yml")}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -121,6 +125,19 @@ pipeline:
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer prepared.Prepared.Output.Close()
|
defer prepared.Prepared.Output.Close()
|
||||||
|
specs := prepared.Invocation.Plan.Specs
|
||||||
|
if len(specs[0].Glossary) != 1 || specs[0].Glossary[0].Name != "Alice" || len(specs[1].Glossary) != 1 || specs[1].Glossary[0].Name != "Shield" {
|
||||||
|
t.Fatalf("selected glossary views: %+v %+v", specs[0].Glossary, specs[1].Glossary)
|
||||||
|
}
|
||||||
|
protectedShield := false
|
||||||
|
for _, term := range specs[0].ProtectedTerms {
|
||||||
|
if term.Spelling == "Shield" && !term.Exempt {
|
||||||
|
protectedShield = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !protectedShield {
|
||||||
|
t.Fatalf("missing protected spell: %+v", specs[0].ProtectedTerms)
|
||||||
|
}
|
||||||
result, err := executePipeline(context.Background(), prepared, func(error) {}, nil)
|
result, err := executePipeline(context.Background(), prepared, func(error) {}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ func TestProcessProtectsRuntimeGlossarySources(t *testing.T) {
|
|||||||
files := map[string]string{
|
files := map[string]string{
|
||||||
"config.yml": "version: 3\nllm: {proposal_profile: fixture}\npipeline: {stages: [{module: grammar}]}\n",
|
"config.yml": "version: 3\nllm: {proposal_profile: fixture}\npipeline: {stages: [{module: grammar}]}\n",
|
||||||
"input.json": `[{"speaker":"Alice","start":0,"end":1,"text":"Hello."}]`,
|
"input.json": `[{"speaker":"Alice","start":0,"end":1,"text":"Hello."}]`,
|
||||||
"runtime.yml": fmt.Sprintf("config:\n imports: [{path: %s, required: true}]\nparty: {entries: []}\n", imported),
|
"runtime.yml": fmt.Sprintf("config:\n imports: [{path: %s, required: true}]\nschema_version: maximumdirect.glossary.v1\ncollections: {party: {entries: []}}\n", imported),
|
||||||
imported: "reference: {entries: []}\n",
|
imported: "collections: {reference: {entries: []}}\n",
|
||||||
"prompts.yml": fmt.Sprintf("profiles:\n - id: fixture\n endpoint: %s/v1\n model: test\n api_key_required: false\n", server.URL),
|
"prompts.yml": fmt.Sprintf("profiles:\n - id: fixture\n endpoint: %s/v1\n model: test\n api_key_required: false\n", server.URL),
|
||||||
}
|
}
|
||||||
for name, data := range files {
|
for name, data := range files {
|
||||||
@@ -70,7 +70,7 @@ func TestProcessProtectsRuntimeGlossarySources(t *testing.T) {
|
|||||||
|
|
||||||
func TestProcessRuntimeGlossaryFailures(t *testing.T) {
|
func TestProcessRuntimeGlossaryFailures(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
files := map[string]string{"config.yml": "version: 3\nglossaries: [party]\npipeline: {stages: [{module: glossary}]}\n", "input.json": `[{"speaker":"Alice","start":0,"end":1,"text":"Hello."}]`, "empty.yml": "party: {entries: []}\n", "bad.yml": "party: [\n"}
|
files := map[string]string{"config.yml": "version: 3\nglossaries: [party]\npipeline: {stages: [{module: glossary}]}\n", "input.json": `[{"speaker":"Alice","start":0,"end":1,"text":"Hello."}]`, "empty.yml": "schema_version: maximumdirect.glossary.v1\ncollections: {party: {entries: []}}\n", "bad.yml": "party: [\n"}
|
||||||
for name, data := range files {
|
for name, data := range files {
|
||||||
if err := os.WriteFile(filepath.Join(dir, name), []byte(data), 0600); err != nil {
|
if err := os.WriteFile(filepath.Join(dir, name), []byte(data), 0600); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -102,10 +102,11 @@ func TestProcessRuntimeGlossaryFailures(t *testing.T) {
|
|||||||
func TestNativeCommandsUseRuntimeGlossary(t *testing.T) {
|
func TestNativeCommandsUseRuntimeGlossary(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
for name, data := range map[string]string{
|
for name, data := range map[string]string{
|
||||||
"left.yml": "version: 3\ncontext: {description: left}\nglossary_collections: {party: {entries: [{id: a, name: Left, category: C}]}}\n",
|
"left.yml": "version: 3\ncontext: {description: left}\nglossary_collections: {party: {entries: [{id: a, name: Left, category: C}]}}\n",
|
||||||
"right.yml": "version: 3\ncontext: {description: right}\nglossary_collections: {party: {entries: [{id: b, name: Right, category: C}]}}\n",
|
"right.yml": "version: 3\ncontext: {description: right}\nglossary_collections: {party: {entries: [{id: b, name: Right, category: C}]}}\n",
|
||||||
"input.yml": "party: {entries: [{id: c, name: Runtime, category: C}]}\n",
|
"input.yml": "schema_version: maximumdirect.glossary.v1\ncollections: {party: {entries: [{id: c, name: Runtime, category: C}]}}\n",
|
||||||
"bad.yml": "party: [\n",
|
"bad.yml": "party: [\n",
|
||||||
|
"additional.yml": "schema_version: maximumdirect.glossary.v1\ncollections: {extra: {entries: [{id: d, name: Additional, category: C}]}}\n",
|
||||||
} {
|
} {
|
||||||
if err := os.WriteFile(filepath.Join(dir, name), []byte(data), 0600); err != nil {
|
if err := os.WriteFile(filepath.Join(dir, name), []byte(data), 0600); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -123,15 +124,16 @@ func TestNativeCommandsUseRuntimeGlossary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
main := filepath.Join(dir, "left.yml")
|
main := filepath.Join(dir, "left.yml")
|
||||||
file := filepath.Join(dir, "input.yml")
|
file := filepath.Join(dir, "input.yml")
|
||||||
code, out, stderr := run("config", "show", "--scope=app", "--config", main, "--glossary-file", file)
|
additional := filepath.Join(dir, "additional.yml")
|
||||||
if code != 0 || !strings.Contains(out, "Runtime") || strings.Contains(out, "name: Left") {
|
code, out, stderr := run("config", "show", "--scope=app", "--config", main, "--glossary-file", file, "--glossary-file", additional)
|
||||||
|
if code != 0 || !strings.Contains(out, "Runtime") || !strings.Contains(out, "Additional") || strings.Contains(out, "name: Left") {
|
||||||
t.Fatalf("show %d %s %s", code, out, stderr)
|
t.Fatalf("show %d %s %s", code, out, stderr)
|
||||||
}
|
}
|
||||||
code, out, stderr = run("config", "explain", "--scope=app", "--config", main, "--glossary-file", file, "--path=/glossary_collections/party/entries")
|
code, out, stderr = run("config", "explain", "--scope=app", "--config", main, "--glossary-file", file, "--path=/glossary_collections/party/entries")
|
||||||
if code != 0 || !strings.Contains(out, "--glossary-file") {
|
if code != 0 || !strings.Contains(out, "--glossary-file") {
|
||||||
t.Fatalf("explain %d %s %s", code, out, stderr)
|
t.Fatalf("explain %d %s %s", code, out, stderr)
|
||||||
}
|
}
|
||||||
code, out, stderr = run("config", "diff", "--details", "--scope=app", "--config", main, "--against-config", filepath.Join(dir, "right.yml"), "--glossary-file", file)
|
code, out, stderr = run("config", "diff", "--details", "--scope=app", "--config", main, "--against-config", filepath.Join(dir, "right.yml"), "--glossary-file", file, "--glossary-file", additional)
|
||||||
if code != 0 || !strings.Contains(out, "left") || !strings.Contains(out, "right") || strings.Contains(out, "glossary_collections") {
|
if code != 0 || !strings.Contains(out, "left") || !strings.Contains(out, "right") || strings.Contains(out, "glossary_collections") {
|
||||||
t.Fatalf("diff %d %s %s", code, out, stderr)
|
t.Fatalf("diff %d %s %s", code, out, stderr)
|
||||||
}
|
}
|
||||||
@@ -170,8 +172,8 @@ func TestRuntimeGlossaryUsesInvocationDirectory(t *testing.T) {
|
|||||||
filepath.Join(project, "secrets", "AUDITA_GLOSSARY_CONTEXT_TEST"): "loaded",
|
filepath.Join(project, "secrets", "AUDITA_GLOSSARY_CONTEXT_TEST"): "loaded",
|
||||||
filepath.Join(project, "glossary.yml"): "reference: {entries: [{id: r, name: Companion, category: C}]}\n",
|
filepath.Join(project, "glossary.yml"): "reference: {entries: [{id: r, name: Companion, category: C}]}\n",
|
||||||
filepath.Join(project, "overlays", "chosen.yml"): "context: {description: overlay}\n",
|
filepath.Join(project, "overlays", "chosen.yml"): "context: {description: overlay}\n",
|
||||||
filepath.Join(invocation, "input.yml"): "config: {imports: [{path: imported.yml}]}\nparty: {entries: [{id: a, name: Incoming, category: C}]}\n",
|
filepath.Join(invocation, "input.yml"): "config: {imports: [{path: imported.yml}]}\nschema_version: maximumdirect.glossary.v1\ncollections: {party: {entries: [{id: a, name: Incoming, category: C}]}}\n",
|
||||||
filepath.Join(invocation, "imported.yml"): "lore: {entries: [{id: b, name: Imported, category: C}]}\n",
|
filepath.Join(invocation, "imported.yml"): "collections: {lore: {entries: [{id: b, name: Imported, category: C}]}}\n",
|
||||||
}
|
}
|
||||||
for path, data := range files {
|
for path, data := range files {
|
||||||
if err := os.WriteFile(path, []byte(data), 0600); err != nil {
|
if err := os.WriteFile(path, []byte(data), 0600); err != nil {
|
||||||
@@ -181,7 +183,54 @@ func TestRuntimeGlossaryUsesInvocationDirectory(t *testing.T) {
|
|||||||
t.Chdir(invocation)
|
t.Chdir(invocation)
|
||||||
var out, stderr bytes.Buffer
|
var out, stderr bytes.Buffer
|
||||||
code := Run(context.Background(), []string{"config", "show", "--scope=app", "--config", filepath.Join(project, "config.yml"), "--overlay", "chosen", "--glossary-file", "input.yml"}, &out, &stderr)
|
code := Run(context.Background(), []string{"config", "show", "--scope=app", "--config", filepath.Join(project, "config.yml"), "--overlay", "chosen", "--glossary-file", "input.yml"}, &out, &stderr)
|
||||||
if code != 0 || !strings.Contains(out.String(), "Incoming") || !strings.Contains(out.String(), "Imported") || !strings.Contains(out.String(), "Companion") || !strings.Contains(out.String(), "overlay") || os.Getenv("AUDITA_GLOSSARY_CONTEXT_TEST") != "loaded" {
|
if code != 0 || !strings.Contains(out.String(), "Incoming") || !strings.Contains(out.String(), "Imported") || strings.Contains(out.String(), "Companion") || !strings.Contains(out.String(), "overlay") || os.Getenv("AUDITA_GLOSSARY_CONTEXT_TEST") != "loaded" {
|
||||||
t.Fatalf("status=%d out=%s err=%s", code, out.String(), stderr.String())
|
t.Fatalf("status=%d out=%s err=%s", code, out.String(), stderr.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSharedGlossaryReadinessBeforeRequests(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
var calls atomic.Int32
|
||||||
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
calls.Add(1)
|
||||||
|
fmt.Fprint(w, `{"choices":[{"message":{"content":"{\"corrections\":[]}"}}]}`)
|
||||||
|
}))
|
||||||
|
defer server.Close()
|
||||||
|
files := map[string]string{
|
||||||
|
"config.yml": "version: 3\nglossaries: [party]\nllm: {proposal_profile: fixture, validation_profile: fixture}\npipeline: {stages: [{module: glossary}]}\nreporting: {enabled: false}\n",
|
||||||
|
"prompts.yml": fmt.Sprintf("profiles: [{id: fixture, endpoint: '%s/v1', model: fixture, api_key_required: false}]\n", server.URL),
|
||||||
|
"input.json": `[{"speaker":"A","start":0,"end":1,"text":"hello"}]`,
|
||||||
|
"good.yml": "schema_version: maximumdirect.glossary.v1\ncollections: {party: {entries: [{id: a, name: Alice, category: person}]}, other: {entries: []}}\n",
|
||||||
|
"empty.yml": "schema_version: maximumdirect.glossary.v1\ncollections: {party: {entries: []}}\n",
|
||||||
|
"invalid.yml": "schema_version: wrong\ncollections: {}\n",
|
||||||
|
}
|
||||||
|
for name, body := range files {
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, command := range []string{"preflight", "process"} {
|
||||||
|
for _, tc := range []struct {
|
||||||
|
file string
|
||||||
|
extra []string
|
||||||
|
wantStatus int
|
||||||
|
}{
|
||||||
|
{"invalid.yml", nil, 2},
|
||||||
|
{"empty.yml", nil, 2},
|
||||||
|
{"good.yml", []string{"--glossaries", `["missing"]`}, 2},
|
||||||
|
} {
|
||||||
|
args := []string{command, "--config", filepath.Join(dir, "config.yml"), "--glossary-file", filepath.Join(dir, tc.file), "--output", filepath.Join(dir, "out.json")}
|
||||||
|
args = append(args, tc.extra...)
|
||||||
|
args = append(args, filepath.Join(dir, "input.json"))
|
||||||
|
var stdout, stderr bytes.Buffer
|
||||||
|
if status := Run(context.Background(), args, &stdout, &stderr); status != tc.wantStatus || calls.Load() != 0 {
|
||||||
|
t.Fatalf("%s %s: status=%d calls=%d stderr=%s", command, tc.file, status, calls.Load(), stderr.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var stdout, stderr bytes.Buffer
|
||||||
|
status := Run(context.Background(), []string{"preflight", "--smoke=false", "--config", filepath.Join(dir, "config.yml"), "--glossary-file", filepath.Join(dir, "good.yml"), "--output", filepath.Join(dir, "out.json"), filepath.Join(dir, "input.json")}, &stdout, &stderr)
|
||||||
|
if status != 0 || calls.Load() != 0 {
|
||||||
|
t.Fatalf("local preflight: status=%d calls=%d stderr=%s", status, calls.Load(), stderr.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user