Files
Agent-Native/adapters/native/r2_regression_test.go
T
weichenandCursor 17f2a4ecfa Close the native P1 gaps the audit listed for this batch
Why: token budget let the current tool batch run, compaction could split a tool pair or race an append, writes were not crash-atomic, and several MCP and session edges only existed as comments.
Evidence: GOWORK=off go test -count=1 -race ./runtime/ ./runtime/llm/ ./runtime/session/ ./runtime/tools/ ./runtime/mcp/ ./adapters/native/ ./adapters/intentgate/ passed, including the TestR2* cases for budget, replacement, cancel, compaction, SSE, UTF-8, schema, MCP retry, session terminate, poison reload, and registry reload.
Impact: over-budget tool calls are skipped and paired; Stop.Replacement is appended to the session; the intent gate can follow Registry.Reload.
Refs: N5, N6, N7, N8, N9, N11, N12, N15, N16, N17, N18, N19, N21, I9
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-03 13:05:58 +00:00

41 lines
983 B
Go

package native
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestR2PoisonMarkerSurvivesNewProcess(t *testing.T) {
dir := t.TempDir()
if err := os.MkdirAll(filepath.Join(dir, ".agentx"), 0o755); err != nil {
t.Fatal(err)
}
transcript := filepath.Join(dir, ".agentx", "transcript.jsonl")
if err := os.WriteFile(transcript, []byte("{}\n"), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(dir, lastFailureFile), []byte("context length exceeded"), 0o644); err != nil {
t.Fatal(err)
}
b := New(Options{})
b.rotateIfPoisoned(dir)
if _, err := os.Stat(transcript); !os.IsNotExist(err) {
t.Fatal("poisoned transcript still at the live path")
}
entries, err := os.ReadDir(filepath.Join(dir, ".agentx"))
if err != nil {
t.Fatal(err)
}
var renamed bool
for _, e := range entries {
if strings.Contains(e.Name(), "transcript.poisoned.") {
renamed = true
}
}
if !renamed {
t.Fatal("expected archived transcript")
}
}