mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
Problem: A redundant arguments envelope makes usable tool calls fail required field validation and can cause repeated model retries. The current CI security scan also reports GO-2026-6809 in the pinned Go 1.26.9 standard library. Root cause: Scheduling, policy checks, execution, and history had no shared representation of effective arguments inside a schema-invalid wrapper. The root and Desktop modules still selected the affected Go patch release. Fix: Unwrap one unambiguous envelope only after full target-schema validation. Use effective arguments for host execution, evidence, decision barriers, and surface actions while retaining the original provider call. Select Go 1.26.10 for both modules so CI and packaged Desktop use the patched standard library. Style the compatibility notice and original-input disclosure like adjacent tool metadata, with a visible expand marker and keyboard focus outline. Verification: The envelope regression suites, provider history, permission, proxy, and interactive surface tests passed. With Go 1.26.10, govulncheck ./... reported zero reachable vulnerabilities and go vet ./... passed. Frontend type and interaction checks passed on the rebased PR. The final card style passed frontend type checking, 16 relevant UI tests, make check, and local browser inspection in light and dark themes with its disclosure closed and open.
49 lines
2.0 KiB
Go
49 lines
2.0 KiB
Go
package usecap
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"reasonix/internal/contract/tool"
|
|
"reasonix/internal/ext/plugin"
|
|
"reasonix/internal/runtime/capability"
|
|
)
|
|
|
|
type envelopeTarget struct{ name string }
|
|
|
|
func (t envelopeTarget) Name() string { return t.name }
|
|
func (envelopeTarget) Description() string { return "" }
|
|
func (envelopeTarget) ReadOnly() bool { return true }
|
|
func (envelopeTarget) Schema() json.RawMessage {
|
|
return json.RawMessage(`{"type":"object","properties":{"path":{"type":"string"}},"required":["path"]}`)
|
|
}
|
|
func (envelopeTarget) Execute(context.Context, json.RawMessage) (string, error) {
|
|
panic("preparation must not execute tools")
|
|
}
|
|
|
|
func TestPrepareProxyArgumentsUsesRegisteredTargetSchemas(t *testing.T) {
|
|
reg := tool.NewRegistry()
|
|
reg.Add(envelopeTarget{"read_file"})
|
|
reg.Add(envelopeTarget{plugin.ModelToolName("docs", "read")})
|
|
proxy := NewUseCapabilityTool(context.Background(), nil, nil, reg, capability.NewLedger(), &capability.Audit{}, func() capability.Catalog { return capability.Catalog{} })
|
|
for _, id := range []string{"tool:read_file", "mcp-tool:docs/read"} {
|
|
raw := json.RawMessage(`{"action":"call","capability_id":"` + id + `","arguments":{"arguments":{"path":"a"}}}`)
|
|
got, changed := tool.PrepareArguments(proxy, raw)
|
|
if !changed || string(proxy.TargetArgs(got)) != `{"path":"a"}` {
|
|
t.Fatalf("%s: target envelope not normalized: %s", id, got)
|
|
}
|
|
}
|
|
for _, raw := range []string{
|
|
`{"action":"call","capability_id":"tool:read_file","arguments":{"path":"a"}}`,
|
|
`{"action":"call","capability_id":"mcp-tool:missing/read","arguments":{"arguments":{"path":"a"}}}`,
|
|
`{"action":"call","capability_id":"tool:read_file","arguments":{"arguments":{"path":"a"}},"action":"search"}`,
|
|
`{"arguments":{"action":"call","capability_id":"tool:read_file","arguments":{"path":"a"}}}`,
|
|
} {
|
|
got, changed := tool.PrepareArguments(proxy, json.RawMessage(raw))
|
|
if changed || string(got) != raw {
|
|
t.Fatalf("legal, unknown, or ambiguous proxy call changed: %s", got)
|
|
}
|
|
}
|
|
}
|