Verify native Scriptorium workflows and retry behavior

This commit is contained in:
2026-11-26 04:34:47 +00:00
parent d48215678a
commit e9d57fb7aa
6 changed files with 201 additions and 30 deletions

View File

@@ -578,24 +578,46 @@ func TestScriptoriumAppHelper(t *testing.T) {
os.Exit(2)
}
runArgs := args[start:]
if path := os.Getenv("SCRIPTORIUM_HELPER_RECORD_PATH"); path != "" {
file, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o600)
if err != nil {
os.Exit(2)
}
if err := json.NewEncoder(file).Encode(runArgs); err != nil {
os.Exit(2)
}
_ = file.Close()
}
outputPath := appSeriatimFlagValue(runArgs, "--out")
if strings.TrimSpace(outputPath) == "" {
outputPath = appSeriatimFlagValue(runArgs, "--output")
}
if strings.TrimSpace(outputPath) == "" {
_, _ = os.Stderr.WriteString("missing output flag\n")
if len(runArgs) >= 4 && strings.Join(runArgs[:3], " ") == "promptkit requirements show" {
inputs := []map[string]any{}
if strings.HasPrefix(runArgs[3], "workflow.") {
inputs = append(inputs, map[string]any{"name": "transcript", "kind": "required"})
if runArgs[3] == "workflow.character" {
inputs = append(inputs, map[string]any{"name": "prior", "kind": "required"})
}
if os.Getenv("SCRIPTORIUM_HELPER_MODE") == "missing-character" && runArgs[3] == "workflow.character" {
inputs = append(inputs, map[string]any{"name": "missing", "kind": "required"})
}
}
_ = json.NewEncoder(os.Stdout).Encode(map[string]any{"prompt_id": runArgs[3], "profile_id": "", "complete": true, "inputs": inputs, "variables": []any{}, "issues": []any{}})
} else if len(runArgs) >= 4 && strings.Join(runArgs[:3], " ") == "promptkit show prepared" {
_, _ = os.Stdout.WriteString(`{"prepared":true}`)
} else if len(runArgs) >= 2 && runArgs[0] == "run" {
if runArgs[1] == "workflow.character" && os.Getenv("SCRIPTORIUM_HELPER_MODE") == "fail-character" {
_, _ = os.Stdout.WriteString("partial")
_, _ = os.Stderr.WriteString("synthetic generation failure")
os.Exit(1)
}
if runArgs[1] == "workflow.parent" || runArgs[1] == "workflow.character" {
_, _ = fmt.Fprint(os.Stdout, "generated ", runArgs[1], "\n")
} else {
_, _ = os.Stdout.WriteString(`{"trim_action":"copy","warnings":[]}`)
}
} else {
_, _ = os.Stderr.WriteString("unsupported scriptorium command\n")
os.Exit(2)
}
if err := os.MkdirAll(filepath.Dir(outputPath), 0o755); err != nil {
_, _ = os.Stderr.WriteString(fmt.Sprintf("mkdir output dir: %v\n", err))
os.Exit(2)
}
if err := os.WriteFile(outputPath, []byte(`{"trim_action":"copy","warnings":[]}`), 0o644); err != nil {
_, _ = os.Stderr.WriteString(fmt.Sprintf("write output: %v\n", err))
os.Exit(2)
}
_, _ = os.Stdout.WriteString("scriptorium helper stdout\n")
_, _ = os.Stderr.WriteString("scriptorium helper stderr\n")
os.Exit(0)
}