Files
Agent-System-Backend/internal/tools/fs_checkpoint_test.go
T
weichen f1302ed5b3 Enable canonical versioned Go module consumption
Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements.

Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate.

Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable.

Refs: Versioned dependencies U1/U3; feature/dependency-workspace
2026-10-13 15:47:16 +00:00

41 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package tools
import (
"encoding/json"
"testing"
core "git-ssh.u1680832.nyat.app/weichen/Agent-System-Core.git"
)
// ---- N3 WP3:backend 自家工具面的回滚资格钉住(验收② 产品侧)----
type checkpointNoteCtx struct {
*fakeFSCtx
noted []string
}
func (c *checkpointNoteCtx) NoteFileCheckpoint(rel string, before []byte, existed bool, after []byte) error {
c.noted = append(c.noted, rel)
return nil
}
// backend 工具面里只有 fs_write_file 写检查点(产品面不暴露编辑工具是刻意的
// 收窄);fs_read_file / fs_list_dir 永不记录。
func TestBackendCheckpointEligibilityIsWriteFileOnly(t *testing.T) {
r := newFSRegistry(t)
ctx := &checkpointNoteCtx{fakeFSCtx: &fakeFSCtx{root: t.TempDir(), owner: "o1", conv: "c1", fsToolsOn: true}}
exec := func(name, args string) {
t.Helper()
r.Execute(ctx, core.ToolCallRequest{CallID: "c-" + name, Name: name, Arguments: json.RawMessage(args)})
}
exec("fs_write_file", `{"path":"a.txt","content":"x"}`)
if len(ctx.noted) != 1 || ctx.noted[0] != "a.txt" {
t.Fatalf("fs_write_file 必须写检查点:%v", ctx.noted)
}
exec("fs_read_file", `{"path":"a.txt"}`)
exec("fs_list_dir", `{"path":"."}`)
if len(ctx.noted) != 1 {
t.Fatalf("读类工具不得写检查点:%v", ctx.noted)
}
}