Why: F02/F04/F15 - contract requests shared one transcript across session scopes, Writable was dropped, and a torn JSONL tail poisoned the next append; pure-text contract results lost their text. Evidence: adapters/native, runtime/session, runtime/tools and conformance tests pass (verify-u2.json); scope-isolation, write-set and torn-tail regression cases added. Impact: empty scope keeps legacy one-shot semantics; identity-less old transcripts are never auto-adopted by a new scope. Refs: feature/agent-stack-audit-remediation-b1 U2
27 lines
720 B
Go
27 lines
720 B
Go
package tools
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestWriteAllowlistRestrictsDocumentTools(t *testing.T) {
|
|
root := t.TempDir()
|
|
reg := WorkspaceTools(root)
|
|
ApplyWriteAllowlist(reg, []string{"allowed.md"})
|
|
|
|
ok := reg.Execute(context.Background(), "write_file", []byte(`{"path":"allowed.md","content":"yes"}`))
|
|
if ok.IsError {
|
|
t.Fatalf("allowed write rejected: %s", ok.Content)
|
|
}
|
|
denied := reg.Execute(context.Background(), "write_file", []byte(`{"path":"other.md","content":"no"}`))
|
|
if !denied.IsError {
|
|
t.Fatal("write outside writable set must fail")
|
|
}
|
|
if _, err := os.Stat(filepath.Join(root, "other.md")); !os.IsNotExist(err) {
|
|
t.Fatal("denied path must not be created")
|
|
}
|
|
}
|