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

This commit is contained in:
archie committed 2026-07-26 20:05:07 +00:00
1 parent 3cab289b41
commit ef12eb6141
3 files changed
+35 -13

No files matched your search

+11 -1
View File
@@ -115,7 +115,17 @@ func TestTaskPayloadWrittenAsVolumeFile(t *testing.T) {
// ── Regression tests for error paths ────────────────────────────────
func TestWriteTaskJSONNonexistentDir(t *testing.T) {
err := WriteTaskJSON("/nonexistent/path/that/does/not/exist", TaskPayload{ID: 1})
// Create a regular file and then try to use a path where that file
// would need to be a directory. Even root cannot mkdir through a
// regular file, making this test reliable regardless of privileges.
f, err := os.CreateTemp("", "archie-test-blocker")
if err != nil {
t.Fatal(err)
}
f.Close()
defer os.Remove(f.Name())
err = WriteTaskJSON(filepath.Join(f.Name(), "subdir"), TaskPayload{ID: 1})
if err == nil {
t.Error("expected error writing to nonexistent directory")
}
+12 -6
View File
@@ -206,14 +206,20 @@ 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 regular file and use a sub-path as the spill directory.
// Even root cannot write a file when a path component is a regular
// file, making this test reliable regardless of privileges.
f, err := os.CreateTemp("", "archie-test-spill-blocker")
if err != nil {
t.Fatal(err)
}
defer func() { _ = os.Chmod(dir, 0o755) }()
f.Close()
defer os.Remove(f.Name())
b := NewTurnBudget(100_000, dir)
// spillDir is a sub-path of the regular file — WriteFile must fail.
spillDir := filepath.Join(f.Name(), "sub")
b := NewTurnBudget(100_000, spillDir)
ref := b.Spill("tool", []byte("data"))
// Spill should handle write failure gracefully.
+12 -6
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"sync/atomic"
"testing"
@@ -583,14 +584,19 @@ func TestDispatchPerToolLimitSpillFailureFallback(t *testing.T) {
// Before fix: the "spill failed" path had no fallback; the per-tool
// 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 regular file and use a sub-path as the spill directory.
// Even root cannot write a file when a path component is a regular
// file, making this test reliable regardless of privileges.
f, err := os.CreateTemp("", "archie-test-spill-blocker")
if err != nil {
t.Fatal(err)
}
defer func() { _ = os.Chmod(dir, 0o755) }()
f.Close()
defer os.Remove(f.Name())
budget := NewTurnBudget(100_000, dir)
spillDir := filepath.Join(f.Name(), "sub")
budget := NewTurnBudget(100_000, spillDir)
e := ToolEntry{
Name: "big-output",
Handler: echoHandler,