Validate providers and retain complete run debugging context

This commit is contained in:
2026-10-09 23:21:01 +01:00
parent f3d829bea5
commit 08b8647d5b
51 changed files with 1036 additions and 159 deletions
+30
View File
@@ -40,3 +40,33 @@ func TestDebugLaunchIsFreshAndQueriesExactRunAndVersion(t *testing.T) {
t.Fatal("historical debugging requires deleted workspace")
}
}
func TestLargeDebugContextIsRetainedWithoutArgumentOverflow(t *testing.T) {
t.Setenv("XDG_CACHE_HOME", t.TempDir())
d := New(&protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 42, Diagnostic: "provider failure"}, Input: map[string]any{"prompt": strings.Repeat("original task", 20000)}}, "/bin/pipelines", "ws://example/connect")
if !strings.Contains(d.Prompt, "original task") {
t.Fatal("large run snapshot discarded")
}
prepared, err := d.Prepare()
if err != nil {
t.Fatal(err)
}
if prepared.ContextFile == "" || len(prepared.Prompt) > 64<<10 {
t.Fatal("packet was not materialized", len(prepared.Prompt))
}
contents, err := os.ReadFile(prepared.ContextFile)
if err != nil || string(contents) != d.Prompt {
t.Fatal("packet lost evidence", err)
}
info, err := os.Stat(prepared.ContextFile)
if err != nil || info.Mode().Perm() != 0600 {
t.Fatal("packet is not private", err)
}
fake := filepath.Join(t.TempDir(), "opencode")
if err = os.WriteFile(fake, []byte("#!/bin/sh\nexit 0\n"), 0700); err != nil {
t.Fatal(err)
}
if err = prepared.Command(context.Background(), fake).Run(); err != nil {
t.Fatal("large-context launch failed", err)
}
}