docs(comments): 注释中文化 · internal/runtime/model + internal/services/backthink(54 文件,纯替换)
- 只翻注释/文档字符串:`go/scanner` 剥注释后按 token 序列+literal 逐 token 比对,**54/54 文件 SAME**;
改动文件总行数与 HEAD 漂移 = 0(严格 1:1,无合并/拆行)
- 裁决编号与 design 节号逐字保留(03.4.1/03.4.2/03.4.3/14.4.1/14.4.5/07.4.2-4、design/04 §3.1/§3.2 等);
`chat_template_kwargs` / `enable_thinking` / `reasoning_effort` / `thinking:{type}` 字段名与形状说明未动
- 存疑译法(已登记):`persona` 在叙事语境用「角色」、标识符语境保留 `persona`(仓库既有模块本身混用);
`rung`→「级」;`provider` 存在「提供商/提供者」两种落笔(可按需一键统一)
- 复核:build/vet 绿 + 两包测试绿;gofmt 干净;残留英文注释 0 条
- 既有存量(未修,只报告):`model/anthropic_test.go` 612 行 >500;`applyAnthropicEvent` 115 行 >80
This commit is contained in:
1 parent
f5cf117482
commit
3dc1232bc2
54 files changed
+1923
-1923
No files matched your search
@@ -10,14 +10,14 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/logger"
|
||||
)
|
||||
|
||||
// defaultListLimit is the number of most-recent records returned by List when the
|
||||
// caller passes a non-positive limit.
|
||||
// defaultListLimit 是调用方传入非正 limit 时,List 返回的
|
||||
// 最近记录条数。
|
||||
const defaultListLimit = 50
|
||||
|
||||
// DDL for the thinking record store. at/created_at follow the project timestamp
|
||||
// convention (RFC3339 with a timezone); trigger and conclusion are the free-text
|
||||
// fields the panel renders; the push_* columns carry a decomposed PushResult so
|
||||
// List need not parse a blob. The primary key is the project-standard auto id.
|
||||
// 思考记录存储的 DDL。at/created_at 遵循项目时间戳
|
||||
// 约定(带时区的 RFC3339);trigger 与 conclusion 是面板渲染的
|
||||
// 自由文本字段;push_* 列携带分解后的 PushResult,
|
||||
// 使 List 不必解析 blob。主键是项目标准的自增 id。
|
||||
const createRecordsSQL = `
|
||||
CREATE TABLE IF NOT EXISTS backthink_records (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -46,10 +46,10 @@ FROM backthink_records
|
||||
ORDER BY id DESC
|
||||
LIMIT ?`
|
||||
|
||||
// Record is one persisted thinking pass (design/12 §4), returned by Store.List
|
||||
// and the service's List. Trigger is the source subsystem label, At the decision
|
||||
// timestamp, Conclusion the runtime's output, ShouldPush the interrupt decision
|
||||
// and PushResult how (or whether) the push went out.
|
||||
// Record 是一轮已持久化的思考(design/12 §4),由 Store.List
|
||||
// 与服务的 List 返回。Trigger 是来源子系统标签,At 是决策
|
||||
// 时间戳,Conclusion 是运行时的输出,ShouldPush 是打扰决策,
|
||||
// PushResult 是推送如何(或是否)发出。
|
||||
type Record struct {
|
||||
ID int64
|
||||
Trigger string
|
||||
@@ -59,17 +59,17 @@ type Record struct {
|
||||
PushResult PushResult
|
||||
}
|
||||
|
||||
// Store persists thinking records in SQLite. It creates its table and index in
|
||||
// NewStore so the module is self-contained (no migration bookkeeping), mirrors
|
||||
// how channel/session creates its own table. It is concurrency-safe by virtue of
|
||||
// the underlying *sql.DB.
|
||||
// Store 把思考记录持久化到 SQLite。它在
|
||||
// NewStore 中建表与索引,因此本模块自包含(无需迁移记账),
|
||||
// 与 channel/session 自建表的做法一致。它凭借底层的 *sql.DB
|
||||
// 而并发安全。
|
||||
type Store struct {
|
||||
db *sql.DB
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
// NewStore builds a Store, ensuring the backthink_records table and index exist.
|
||||
// It returns ErrNilDB when db is nil. ctx is used for the DDL.
|
||||
// NewStore 构建 Store,确保 backthink_records 表与索引存在。
|
||||
// db 为 nil 时返回 ErrNilDB。ctx 用于 DDL。
|
||||
func NewStore(ctx context.Context, db *sql.DB, log *slog.Logger) (*Store, error) {
|
||||
if db == nil {
|
||||
return nil, ErrNilDB
|
||||
@@ -84,7 +84,7 @@ func NewStore(ctx context.Context, db *sql.DB, log *slog.Logger) (*Store, error)
|
||||
return &Store{db: db, log: log}, nil
|
||||
}
|
||||
|
||||
// Append persists r and returns the new record id.
|
||||
// Append 持久化 r 并返回新记录 id。
|
||||
func (s *Store) Append(ctx context.Context, r Record) (int64, error) {
|
||||
res, err := s.db.ExecContext(ctx, insertRecordSQL,
|
||||
r.Trigger,
|
||||
@@ -109,8 +109,8 @@ func (s *Store) Append(ctx context.Context, r Record) (int64, error) {
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// List returns the most recent records newest-first. A non-positive limit selects
|
||||
// defaultListLimit.
|
||||
// List 返回最近的记录,最新的在前。非正的 limit 选用
|
||||
// defaultListLimit。
|
||||
func (s *Store) List(ctx context.Context, limit int) ([]Record, error) {
|
||||
if limit <= 0 {
|
||||
limit = defaultListLimit
|
||||
@@ -158,7 +158,7 @@ func (s *Store) List(ctx context.Context, limit int) ([]Record, error) {
|
||||
return records, nil
|
||||
}
|
||||
|
||||
// boolInt maps a bool to the SQLite INTEGER 1/0 representation.
|
||||
// boolInt 把 bool 映射为 SQLite 的 INTEGER 1/0 表示。
|
||||
func boolInt(b bool) int {
|
||||
if b {
|
||||
return 1
|
||||
@@ -166,11 +166,11 @@ func boolInt(b bool) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// intBool maps a SQLite INTEGER to a bool.
|
||||
// intBool 把 SQLite 的 INTEGER 映射为 bool。
|
||||
func intBool(n int) bool { return n != 0 }
|
||||
|
||||
// parseTime parses a stored RFC3339(nano/with-zone) timestamp, falling back to
|
||||
// the zero time so a malformed row never breaks a listing.
|
||||
// parseTime 解析存储的 RFC3339(带纳秒/时区)时间戳,失败时回退到
|
||||
// 零值时间,因此格式错乱的行绝不会破坏列表查询。
|
||||
func parseTime(s string) time.Time {
|
||||
for _, layout := range []string{time.RFC3339Nano, time.RFC3339} {
|
||||
if t, err := time.Parse(layout, s); err == nil {
|
||||
|
||||
Reference in new issue
Block a user