fix: baseline gate repair (go test ./... -count=1)

This commit is contained in:
archie committed 2026-07-26 19:41:12 +00:00
1 parent 3cab289b41
commit a7054250ff
3 files changed
+26 -12

No files matched your search

+9 -2
View File
@@ -42,9 +42,16 @@ type TaskPayload struct {
}
// WriteTaskJSON writes the task payload to <workspace>/task.json.
// The workspace directory must already exist; WriteTaskJSON will not
// create directories.
func WriteTaskJSON(workspace string, payload TaskPayload) error {
if err := os.MkdirAll(workspace, 0o755); err != nil {
return fmt.Errorf("task.json dir: %w", err)
if workspace == "" {
return fmt.Errorf("task.json: empty workspace path")
}
if info, err := os.Stat(workspace); err != nil {
return fmt.Errorf("task.json: workspace %s: %w", workspace, err)
} else if !info.IsDir() {
return fmt.Errorf("task.json: workspace %s is not a directory", workspace)
}
data, err := json.Marshal(payload)
if err != nil {
+8 -5
View File
@@ -207,13 +207,16 @@ func TestTurnBudgetSpillFileNaming(t *testing.T) {
func TestTurnBudgetSpillDirPermissions(t *testing.T) {
dir := t.TempDir()
// Make dir read-only.
if err := os.Chmod(dir, 0o444); err != nil {
t.Fatalf("chmod: %v", err)
// Create a file where we need a directory component so that
// os.WriteFile fails with ENOTDIR even when running as root.
blocker := filepath.Join(dir, "blocker")
if err := os.WriteFile(blocker, nil, 0o644); err != nil {
t.Fatalf("write blocker: %v", err)
}
defer func() { _ = os.Chmod(dir, 0o755) }()
// spillDir includes "blocker" as a parent, but blocker is a file.
spillDir := filepath.Join(dir, "blocker", "sub")
b := NewTurnBudget(100_000, dir)
b := NewTurnBudget(100_000, spillDir)
ref := b.Spill("tool", []byte("data"))
// Spill should handle write failure gracefully.
+9 -5
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"sync/atomic"
"testing"
@@ -584,13 +585,16 @@ func TestDispatchPerToolLimitSpillFailureFallback(t *testing.T) {
// limit was silently bypassed, leaving the full 500-char preview.
dir := t.TempDir()
// Make spill directory read-only to force write failure.
if err := os.Chmod(dir, 0o444); err != nil {
t.Fatalf("chmod: %v", err)
// Create a file where we need a directory component so that
// os.WriteFile fails with ENOTDIR even when running as root.
blocker := filepath.Join(dir, "blocker")
if err := os.WriteFile(blocker, nil, 0o644); err != nil {
t.Fatalf("write blocker: %v", err)
}
defer func() { _ = os.Chmod(dir, 0o755) }()
// spillDir includes "blocker" as a parent, but blocker is a file.
spillDir := filepath.Join(dir, "blocker", "sub")
budget := NewTurnBudget(100_000, dir)
budget := NewTurnBudget(100_000, spillDir)
e := ToolEntry{
Name: "big-output",
Handler: echoHandler,