feat(orchestration/audit): 子代理上下文可审计查询(全量/尾部/关键词定位)+ 主代理代审授权(审计日志+小字)

This commit is contained in:
Aska committed 2026-09-06 05:39:06 +08:00
1 parent 71697ca4f8
commit 8b723009f9
5 files changed
+658

No files matched your search

@@ -0,0 +1,24 @@
// Package audit provides the subagent-auditing primitives specified by the
// Cyrene orchestration design (DevDocs/design/05-子代理.md §3 and §6) and the
// security/audit requirements in DevDocs/design/11-安全与权限.md §4 and §8.
//
// It has two halves:
//
// - ContextAuditor gives a main agent read-only, traceable access to a
// subagent's context (a []model.Message) so it can audit and pinpoint what
// the subagent did: the full context, a tail window, or a keyword hit with
// its surrounding lines. It is a pure value type over the message list the
// orchestral layer hands it; it holds no storage and no policy.
//
// - Approver records a main-agent review-and-approve (代审授权) of a
// subagent's sensitive action. It writes a structured audit log (who / what
// / when / result) and produces the short frontend notice "「xxx 想要干什么,
// 我审查后批准了」". Whether an action is actually sensitive and whether it is
// allowed is decided by the upper policy layer; this package only records,
// narrates, and returns the result model — it never judges permission.
//
// The package is a leaf: it depends only on the standard library,
// internal/runtime/model and internal/logger, and never imports the agent loop
// or other runtime packages, so it can sit inside runtime/orchestration without
// an import cycle.
package audit