docs(cyrene): cmd/cyrene 存量英文注释中文化(22 个非测试文件,仅注释)
- 四组并行完成:main/wire*.go、wire_capacity|channels|runtime、channels|persona_*|emotion|observability、 voice|plugins|stream|skills|vision|subagent_tool|extractor|mcp|sessionread_tool|terminal_tool。 - 机械校验(git diff -U0 去 // 行与空行)仅剩 wire_frontend.go:84 一处行尾注释:代码前缀 「\ta.gw = gw 」经 cat -A 与 HEAD 逐字节比对一致(allow 清单已声明)。 - 验收:隔离 worktree(HEAD + 本批 patch)go build/vet 绿、全树 58 包 ok、 linux/amd64 + darwin/arm64 交叉编译绿;gofmt -l 干净。 - 备注:整树两次红均为负载敏感 flake(backthink / orchestration 的 timeout 类用例单独 -count=20 全过)。
This commit is contained in:
1 parent
5c2189efb0
commit
52f08dc343
22 files changed
+455
-586
No files matched your search
+22
-28
@@ -35,24 +35,22 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/user"
|
||||
)
|
||||
|
||||
// defaultOwnerPath and defaultPersonasDir point at the on-disk persona/owner
|
||||
// definitions shipped with the repo; they are relative to the working directory.
|
||||
// defaultOwnerPath 与 defaultPersonasDir 指向随仓库分发的磁盘上人格/主人定义,
|
||||
// 路径相对工作目录。
|
||||
const (
|
||||
defaultOwnerPath = "configs/users/owner.yaml"
|
||||
defaultPersonasDir = "configs/personas"
|
||||
defaultSQLitePath = "./data/cyrene.db"
|
||||
fallbackInstruction = "You are Cyrene, a warm and attentive companion."
|
||||
|
||||
// Bound/knob constants. Compile-time so no bare magic number appears in the
|
||||
// runtime path (project rule §10).
|
||||
// 上界与旋钮常量。编译期定值,运行时路径上不出现裸魔法数字(项目规范 §10)。
|
||||
defaultMaxRounds = 8
|
||||
defaultMaxParallel = 4
|
||||
defaultAgentID = "orchestrator"
|
||||
defaultToolTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
// app holds every subsystem the single Cyrene binary assembles. It is built by
|
||||
// newApp and torn down by close on shutdown.
|
||||
// app 持有单二进制 Cyrene 组装的全部子系统:由 newApp 构建,关闭时由 close 拆除。
|
||||
type app struct {
|
||||
cfg *config.Config
|
||||
log *slog.Logger
|
||||
@@ -84,33 +82,29 @@ type app struct {
|
||||
gw *gateway.Server
|
||||
channelBridge *channelbridge.Bridge
|
||||
channels gateway.ChannelConfigStore
|
||||
// capacitySink broadcasts capacity_awaken transitions to the Web UI (design/14
|
||||
// §5). It is satisfied by *gateway.Server (BroadcastCapacityAwaken); held as an
|
||||
// interface so the composition root is unit-testable with a fake sink.
|
||||
// capacitySink 把 capacity_awaken 状态迁移广播给 Web UI(design/14 §5)。
|
||||
// 由 *gateway.Server 满足(BroadcastCapacityAwaken);以接口形式持有,
|
||||
// 组合根才能用假出口做单元测试。
|
||||
capacitySink capacityEmitter
|
||||
// emotion applies each settled turn to the bound persona's emotion machine and
|
||||
// affection (design/01 §2) and hands the changes to moodSink. Nil when no
|
||||
// persona was registered, in which case no mood is tracked or persisted.
|
||||
// emotion 把每一轮落定的对话施加到所绑人格的情绪机与好感度上(design/01 §2),
|
||||
// 并把变化交给 moodSink。没有注册人格时为 nil,此时不追踪、不持久化任何心情。
|
||||
emotion *emotion.Observer
|
||||
// moodSink broadcasts a mood change to the Web UI (design/07 §3). It is
|
||||
// satisfied by *gateway.Server (BroadcastMood); held as an interface so the
|
||||
// composition root is unit-testable with a fake sink.
|
||||
// moodSink 把心情变化广播给 Web UI(design/07 §3)。由 *gateway.Server 满足
|
||||
// (BroadcastMood);以接口形式持有,组合根才能用假出口做单元测试。
|
||||
moodSink moodEmitter
|
||||
// traceWriter fans finished trace spans out to the JSONL stderr recorder and,
|
||||
// once the gateway exists, to the gateway's observability buffer behind
|
||||
// GET /api/v1/admin/observability/trace (design/19 §2). It is held so
|
||||
// wireFrontend can register the gateway sink on the already-running tracer.
|
||||
// traceWriter 把完成的 trace span 扇出到 JSONL stderr 记录器,网关出现后也送往
|
||||
// 网关的可观测性缓冲(挂在 GET /api/v1/admin/observability/trace 后面,
|
||||
// design/19 §2)。持有它是为了让 wireFrontend 能往已在运行的 tracer 上注册
|
||||
// 网关出口。
|
||||
traceWriter *traceFanout
|
||||
}
|
||||
|
||||
// newApp assembles the full Cyrene runtime from cfg and log. It opens the
|
||||
// database, migrates the schema, wires the persona registry, model adapter, tool
|
||||
// dispatcher, memory stack, agent loop, orchestration, execution, IoT, channel
|
||||
// sessions/adapters and the gateway, and returns the ready app.
|
||||
// newApp 依据 cfg 与 log 组装完整的 Cyrene 运行时:打开数据库、迁移表结构,接线
|
||||
// 人格注册表、模型适配器、工具分发器、记忆栈、agent 循环、编排、执行、IoT、
|
||||
// 渠道会话/适配器与网关,最后返回就绪的 app。
|
||||
//
|
||||
// Fatal wiring failures (database open/migrate, required auth, gateway) are
|
||||
// returned as errors; optional subsystems degrade gracefully so the binary can
|
||||
// boot even when a model key or external channel is not configured.
|
||||
// 致命的接线失败(数据库打开/迁移、必需的认证、网关)以错误返回;可选子系统则
|
||||
// 优雅降级,使得未配置模型密钥或外部渠道时二进制仍能启动。
|
||||
func newApp(ctx context.Context, cfg *config.Config, log *slog.Logger) (*app, error) {
|
||||
dataDir := resolveDataDir(cfg)
|
||||
databasePath := resolveSQLitePath(cfg, dataDir)
|
||||
@@ -136,8 +130,8 @@ func newApp(ctx context.Context, cfg *config.Config, log *slog.Logger) (*app, er
|
||||
caps: registry.New(),
|
||||
}
|
||||
|
||||
// Release already-opened resources if any later wiring step fails, without
|
||||
// the full-service shutdown log (a partial boot is not a clean shutdown).
|
||||
// 后续任一接线步骤失败时,释放已经打开的资源,但不打整套服务关闭日志
|
||||
// (半途启动不等同于一次干净退出)。
|
||||
completed := false
|
||||
defer func() {
|
||||
if completed {
|
||||
|
||||
Reference in new issue
Block a user