Add prompt input materials and session IDs

This commit is contained in:
2026-07-05 17:51:36 +00:00
parent 291298cf7b
commit 49d94cc2e9
7 changed files with 423 additions and 39 deletions

View File

@@ -739,6 +739,102 @@ func TestRunPipelineLLMProfileOverrideSelectsFactoryProfile(t *testing.T) {
}
}
func TestRunPipelineSessionIDFlagRecordsExplicitTrimmedValue(t *testing.T) {
configPath := writeTestConfig(t, mvpConfigYAML("dnd-session", "dnd/spells"))
inputPath := writeSeriatimInput(t)
outputDir := t.TempDir()
diagnosticsDir := t.TempDir()
var stdout bytes.Buffer
var stderr bytes.Buffer
code := RunWithOptions([]string{
"run", "dnd-session",
"--config", configPath,
"--input", inputPath,
"--session-id", " external-session ",
"--output-dir", outputDir,
"--diagnostics-dir", diagnosticsDir,
}, &stdout, &stderr, Options{
LLMClientFactory: fakeLLMFactory(newFakeRunLLMClient(false), nil),
})
if code != 0 {
t.Fatalf("RunWithOptions() code = %d, stderr=%q", code, stderr.String())
}
var manifest artifacts.RunManifest
readJSONFile(t, filepath.Join(onlyChildDir(t, outputDir), "manifest.json"), &manifest)
if got := manifest.Metadata["session_id"]; got != "external-session" {
t.Fatalf("manifest metadata = %#v, want trimmed session ID", manifest.Metadata)
}
}
func TestRunPipelineSessionIDDefaultsToParsedSourceID(t *testing.T) {
configPath := writeTestConfig(t, mvpConfigYAML("dnd-session", "dnd/spells"))
inputPath := writeSeriatimInput(t)
outputDir := t.TempDir()
diagnosticsDir := t.TempDir()
var stdout bytes.Buffer
var stderr bytes.Buffer
code := RunWithOptions([]string{
"run", "dnd-session",
"--config", configPath,
"--input", inputPath,
"--output-dir", outputDir,
"--diagnostics-dir", diagnosticsDir,
}, &stdout, &stderr, Options{
LLMClientFactory: fakeLLMFactory(newFakeRunLLMClient(false), nil),
})
if code != 0 {
t.Fatalf("RunWithOptions() code = %d, stderr=%q", code, stderr.String())
}
var manifest artifacts.RunManifest
readJSONFile(t, filepath.Join(onlyChildDir(t, outputDir), "manifest.json"), &manifest)
if got := manifest.Metadata["session_id"]; got != "session-alpha" {
t.Fatalf("manifest metadata = %#v, want parsed source ID default", manifest.Metadata)
}
}
func TestRunPipelineSessionIDFlagRejectsMissingOrBlankValue(t *testing.T) {
configPath := writeTestConfig(t, mvpConfigYAML("dnd-session", "dnd/spells"))
inputPath := writeSeriatimInput(t)
tests := []struct {
name string
args []string
want string
}{
{
name: "missing value",
args: []string{"run", "dnd-session", "--config", configPath, "--input", inputPath, "--session-id"},
want: "flag needs an argument",
},
{
name: "blank value",
args: []string{"run", "dnd-session", "--config", configPath, "--input", inputPath, "--session-id", " \t "},
want: "--session-id must not be empty",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var stdout bytes.Buffer
var stderr bytes.Buffer
code := RunWithOptions(test.args, &stdout, &stderr, Options{
LLMClientFactory: fakeLLMFactory(newFakeRunLLMClient(false), nil),
})
if code != 2 {
t.Fatalf("RunWithOptions() code = %d, want 2", code)
}
if !strings.Contains(stderr.String(), test.want) {
t.Fatalf("stderr = %q, want substring %q", stderr.String(), test.want)
}
})
}
}
func TestRunPipelineReferenceFlagBindsUnambiguousSlot(t *testing.T) {
configPath := writeTestConfig(t, testConfigYAML("example", "events"))
inputPath := filepath.Join(t.TempDir(), "missing.json")
@@ -1478,6 +1574,10 @@ func TestRunPipelineReferenceBytesProduceDistinctManifests(t *testing.T) {
if !reflect.DeepEqual(resolvedReferences, manifest.References) {
t.Fatalf("resolved references = %#v, want manifest references %#v", resolvedReferences, manifest.References)
}
runManifestJSON := string(readFile(t, filepath.Join(onlyChildDir(t, diagnosticsDir), diagnostics.ArtifactRunManifest)))
if strings.Contains(runManifestJSON, "source text") || strings.Contains(runManifestJSON, referenceText) {
t.Fatalf("run manifest diagnostics contains raw prompt material: %s", runManifestJSON)
}
resolvedReferenceJSON := string(readFile(t, filepath.Join(onlyChildDir(t, diagnosticsDir), diagnostics.ArtifactResolvedReferences)))
if strings.Contains(resolvedReferenceJSON, referenceText) || strings.Contains(resolvedReferenceJSON, "content") {
t.Fatalf("resolved references diagnostics contains content: %s", resolvedReferenceJSON)