Files
Agent-Intent/intent/generator.go
weichen 765a7e7177 Isolate snapshots and validate generated commands
Why: F07/F08 - registry and catalog accessors shared caller-mutable
nested state, and the generation fallback skipped full slot validation,
risk metadata and mis-keyed handler slot tables.
Evidence: intent package tests pass incl. new isolation/generated cases
(verify-u5.json).
Impact: no exported signature change; rule and generated paths now share
authoritative validation.
Refs: feature/agent-stack-audit-remediation-b1 U5
2026-10-21 15:41:31 +00:00

18 lines
933 B
Go
Raw Permalink 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 intent
import "context"
// CommandGenerator 模型命令生成端口(I2):宿主用模型实现
// (借鉴 Rasa 的 LLM command generators:只把相关流程交给生成器)。
// 只在规则与语义都未命中(fallback)时被调用;实现自担延迟与成本。
// 返回错误时识别保持 fallback,不会使 Recognize 失败。
//
// 库侧校验:start 的 ActionRef 必须能从同一快照唯一解析回权威 spec
// (spec ID、Action 别名、或唯一 handler 反查);槽位键必须在目标 spec
// 键集内,随后跑与规则路径同款的必填/枚举/format 校验并挂上元数据。
// 解析失败或未知键一律 fail-closed 回 fallback。
type CommandGenerator interface {
// Generate 基于输入与能力目录产出命令列表(catalog 由调用方按 top-k 给)。
Generate(ctx context.Context, input string, catalog []CatalogSpec) ([]Command, error)
}