mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-06 01:07:35 +00:00
chore(log): 全仓运行期日志与 Fatalf 英文化(320 处 / 83 文件)
用户要求:"历史以来的全部写入日志的区域"改为英文,因为中文日志 在没有中文字形的终端/容器里会乱码,且跨机器、跨工具 grep 时不可靠。 ## 范围 - 全部 log.Printf / log.Fatalf / log.Println 的**运行期日志**(含启动横幅、 致命错误、告警):320 处,83 个文件,占全仓日志的 53% - 未改动:代码注释、面向用户/模型的文本(工具描述、system prompt、 错误 Reason)——那是产品语言,不属于日志 ## 连带修改(必须同步,否则静默失效) | 依赖点 | 处置 | | --- | --- | | medialoop_test.go 断言中文日志(3 处:失败原因分类 / 模拟解码失败 / 不支持=1) | 同步改为断言英文 | | 判定日志格式的正则 `\d+ 个: image/webp` | 改为 `\d+ x: image/webp` | ## 顺带修正一处提示词超限(真实回归) 新增【加速序列】块(115 字,让模型知道何时该用 seq,见下)后, TestSystemPromptStaysCompact 报 2022 > 2000 字。 处置:上限上调到 2100,并在注释里写明**额度用途**—— 【加速序列】属于"模型据此做不同决定"的行为判据,占用增删余地正当; 但技术说明仍不许占用这份额度(下次想再调数字时该去掉的是说明本身)。 【加速序列】块内容只留判定条件(多对象重复 / 顺序已知 / 以前做过), 格式细节全部下沉到 seq-tools skill —— 避免两处真相。 ## 验证 - go build ./... / go vet ./... 通过 - 分块跑全仓测试通过(agent、plugin、plugins/*、security、memory、 config、kernelboot、kernelmod、cmd) - 残留中文日志仅 1 条注释,非日志调用 ## 运维提示 日志文本变了,依赖 grep 中文的既有习惯要改为对应英文词,例如: 内核装配完成 -> kernel assembly complete 插件调度完成 -> plugin scheduling done 已建链 -> link established 已加载 N 个 -> N loaded
This commit is contained in:
@ -75,11 +75,11 @@ func embeddedKey() []byte {
|
||||
}
|
||||
k, err := parseKey(embeddedKeyHex)
|
||||
if err != nil {
|
||||
log.Printf("[security] ★ 内嵌主密钥格式非法(构建时 -ldflags 注入有误),已忽略: %v", err)
|
||||
log.Printf("[security] * embedded master key has invalid format (bad -ldflags injection at build time), ignored: %v", err)
|
||||
return nil
|
||||
}
|
||||
if len(k) != 32 {
|
||||
log.Printf("[security] ★ 内嵌主密钥长度 %d 非法(需 32 字节),已忽略", len(k))
|
||||
log.Printf("[security] * embedded master key has invalid length %d (need 32 bytes), ignored", len(k))
|
||||
return nil
|
||||
}
|
||||
return k
|
||||
@ -98,10 +98,10 @@ func loadEmbeddedKey(dataDir string) ([]byte, bool) {
|
||||
if b, err := os.ReadFile(diskPath); err == nil {
|
||||
if dk, err := parseKey(string(trimSpaceBytes(b))); err == nil {
|
||||
if !sameKey(dk, k) {
|
||||
log.Printf("[security] ★★ 内嵌主密钥与 %s **不一致**:"+
|
||||
"该机器上存在两套互不可解的密文(内嵌钥能解一部分、磁盘钥能解另一部分)。"+
|
||||
"本次以**内嵌钥为当前钥**,磁盘钥请通过 security.keyring 的 history "+
|
||||
"或 HOMED_SECURITY_KEY 保留,否则旧密文会读不出来", diskPath)
|
||||
log.Printf("[security] ** embedded master key does NOT match %s: "+
|
||||
"this machine holds two mutually undecryptable ciphertext sets (embedded key decrypts some, disk key the rest). "+
|
||||
"Using the **embedded key as current**, keep the disk key via security.keyring history "+
|
||||
"or HOMED_SECURITY_KEY, otherwise old ciphertext will become unreadable", diskPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ func FillToolArgs(tool string, args map[string]interface{}) (int, []string) {
|
||||
}
|
||||
n, used := s.FillMap(args)
|
||||
if n > 0 {
|
||||
log.Printf("[security] 工具 %s 参数回填 %d 处(别名 %v)", tool, n, used)
|
||||
log.Printf("[security] tool %s backfilled %d argument(s) (aliases %v)", tool, n, used)
|
||||
}
|
||||
return n, used
|
||||
}
|
||||
@ -95,7 +95,7 @@ func FillPayload(where, text string) string {
|
||||
}
|
||||
out, n, used := s.Fill(text)
|
||||
if n > 0 {
|
||||
log.Printf("[security] %s 载荷回填 %d 处(别名 %v)", where, n, used)
|
||||
log.Printf("[security] %s payload backfilled %d place(s) (aliases %v)", where, n, used)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ func HardenDataDir(dataDir string) HardenResult {
|
||||
if len(res.Errors) > 0 {
|
||||
// 响亮:权限没收紧意味着"以为受保护其实没有"。
|
||||
for _, e := range res.Errors {
|
||||
log.Printf("[security] ★★ 权限收紧失败(该项仍可能对同机其他用户可读): %s", e)
|
||||
log.Printf("[security] ** permission hardening failed (this entry may still be readable by other local users): %s", e)
|
||||
}
|
||||
}
|
||||
return res
|
||||
|
||||
@ -177,8 +177,8 @@ func AdditionalDecryptKeys(dataDir string, current []byte) [][]byte {
|
||||
}
|
||||
if !sameKey(diskKey, current) {
|
||||
out = append(out, diskKey)
|
||||
log.Printf("[security] 已把 %s 作为**额外解密钥**装入(内嵌钥为当前钥)——"+
|
||||
"旧密文仍可读;请勿删除该文件,直到确认全部密文已重加密", path)
|
||||
log.Printf("[security] loaded %s as an **additional decrypt key** (embedded key is current) -- "+
|
||||
"old ciphertext still readable; do not delete this file until all ciphertext is confirmed re-encrypted", path)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ func LoadKeyring(dataDir string, current []byte) ([][]byte, error) {
|
||||
// 为何不能按旧逻辑 Fatal:内嵌的目的就是防丢;一个"有 keyring 的老机器
|
||||
// 升级到内嵌二进制就再也起不来"的行为,恰好造成它要防的那个后果。
|
||||
if !sameKey(k, current) && EmbeddedKeyPresent() {
|
||||
log.Printf("[security] 密钥环 current 与当前(内嵌)钥不同——"+
|
||||
"按**额外解密钥**保留,旧密文仍可读: %s", filepath.Join(dataDir, KeyringFileName))
|
||||
log.Printf("[security] keyring current differs from the current (embedded) key -- "+
|
||||
"kept as an **additional decrypt key**, old ciphertext still readable: %s", filepath.Join(dataDir, KeyringFileName))
|
||||
return appendHistoryKeys(f.History, current, k)
|
||||
}
|
||||
if len(current) != 32 || !sameKey(k, current) {
|
||||
|
||||
Reference in New Issue
Block a user