guanghu-ice-heart/server-tools/codex-session-cognition-archive/README.md

52 lines
1.9 KiB
Markdown
Raw 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.

# Codex 会话冷归档与开发认知链
这个模块把 Codex 会话分成三个互不冒充的层:
1. `raw objects`JZAO 私有、内容寻址的原始 JSONL 证据;
2. `private index`JZAO 私有、脱敏后的可见交流和工程事件索引;
3. `reviewed cognition`:人工或人格体复核后才能进入 REPO-012 的认知卡片。
原始会话和私有索引禁止直接推入代码仓库。索引明确排除:
- `reasoning``encrypted_content`
- 工具参数、工具输出和命令正文;
- 私钥、授权头、令牌、密码、邮箱、IP 与疑似高熵秘密。
## 增量归档
```bash
COPYFILE_DISABLE=1 node archive.mjs archive \
--source "$HOME/.codex/sessions" \
--destination "/Volumes/JZAO/HoloLake/codex-session-archives"
```
默认最近五分钟仍有写入的会话记为 `pending_live`,不会冒充完整归档。后续再次运行即可形成
新快照和新对象,内容相同的文件自动去重。
归档过程被断电、拔盘或系统卸载打断时,已完成对象仍按内容哈希保留,`.staging` 中的临时
文件不算完成。确认卷通过文件系统检查后重新运行即可续建;程序会去重已完成对象,并在
成功快照结束时清除本归档目录内的 AppleDouble 旁文件。
## 独立校验
```bash
COPYFILE_DISABLE=1 node archive.mjs verify \
--destination "/Volumes/JZAO/HoloLake/codex-session-archives" \
--manifest "/Volumes/JZAO/HoloLake/codex-session-archives/snapshots/<时间>/manifest.json"
```
只有原始对象和私有索引都通过 SHA-256 回读、且没有 AppleDouble 文件时,归档能力才是
`100`
## 恢复
默认只生成恢复计划:
```bash
node archive.mjs restore \
--destination "/Volumes/JZAO/HoloLake/codex-session-archives" \
--manifest "<manifest.json>" \
--restore-root "/安全的新目录"
```
确认目标是空目录后加 `--execute`。恢复器不会覆盖内容不同的现有文件。