ci / vet-and-test (pull_request) Successful in 41s
Why: N1 increment three host side - plugin agent assets must reject hooks/mcp/permissionMode declarations (WP1 acceptance), and squad members need the kernel ask port wired to the HITL card (WP4). Evidence: go vet clean; go test ./... 29 packages ok, including new agent-asset tests (banned keys located to the field, unknown keys, missing id) and the V2 asset suite. Nested pins at native c5b9dca (PR #18) and squad fc9620e (PR #17). Impact: plugins agents/ assets now parse via parseAgentAsset (strict JSON with banned-key rejection); PermissionAskOf exported and takes any host with the optional method; app.go wires cfg.PermissionAsk for the squad path. Legacy behavior unchanged when nothing registers the port. Refs: Documents proposal 2026-10-07-agent-stack-n1q1i1-plans.md WP1/WP4
36 lines
919 B
Go
36 lines
919 B
Go
package runtime
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
nruntime "agent-native/runtime"
|
|
agentllm "agent-native/runtime/llm"
|
|
)
|
|
|
|
// PermissionAskOf 只在宿主实现内核级询问时接线;否则返回 nil,
|
|
// 内核保持「ask 按拒绝处理」的旧行为。
|
|
func TestPermissionAskOfOptional(t *testing.T) {
|
|
type plain struct{ RunCtx }
|
|
if got := PermissionAskOf(plain{}); got != nil {
|
|
t.Fatal("plain rc returned a non-nil ask port, want nil")
|
|
}
|
|
}
|
|
|
|
func TestPermissionAskOfWired(t *testing.T) {
|
|
type asker struct{ RunCtx }
|
|
wired := PermissionAskOf(askStub{})
|
|
if wired == nil {
|
|
t.Fatal("wired rc returned nil")
|
|
}
|
|
if v := wired(context.Background(), agentllm.ToolCall{Name: "run_shell"}); !v.Allow {
|
|
t.Fatalf("verdict = %+v", v)
|
|
}
|
|
}
|
|
|
|
type askStub struct{ RunCtx }
|
|
|
|
func (askStub) PermissionAsk(ctx context.Context, call agentllm.ToolCall) nruntime.AskVerdict {
|
|
return nruntime.AskVerdict{Allow: true}
|
|
}
|