Skip to content

fix: add session-log migration tool for pre-0.1.0 logs (Fixes #19) - #21

Open
uluckystar wants to merge 1 commit into
NanmiCoder:mainfrom
uluckystar:fix/migrate-session-logs
Open

fix: add session-log migration tool for pre-0.1.0 logs (Fixes #19)#21
uluckystar wants to merge 1 commit into
NanmiCoder:mainfrom
uluckystar:fix/migrate-session-logs

Conversation

@uluckystar

Copy link
Copy Markdown

Fixes #19 — 存量会话日志迁移工具。

背景

0.1.0 及更早版本(以及 #8 修复前的本地构建)写入会话日志的 agent-teams/* 事件没有携带 ignorable 信封标记。harness 的持久化协调器会拒绝解释任何包含"未知且未标记 ignorable"事件类型的日志:

SessionFormatUnsupportedError: ... contains event type "agent-teams/task-created" ...
unknown to this harness and not marked ignorable; refusing to interpret the log

#8/#9 修复了新写入,但存量会话的日志仍然打不开,#19 请求提供迁移工具。

改动

  • scripts/migrate-session-logs.mjs(新增,零依赖,仅 Node 内置 zstd):
    • 解码日志的每个 Zstandard 帧(按 harness JSONL 后端的帧布局扫描)
    • 只给缺失标记的 agent-teams/* 事件插入 "ignorable": true,其余字节原样保留
    • 以"头帧 + 单 body 帧"重新编码(与 harness 读取器兼容,checksum 与写入端一致)
    • 幂等:无缺失标记的日志原样不动(不产生写入)
    • 结构校验:损坏/撕裂帧会报错而不是静默改写
    • 内置 --self-test:内存构造合成日志验证插入与幂等性
  • README.md:新增「存量日志迁移」章节,给出 find ... -exec 一键迁移命令与自检方式

验证

  • node scripts/migrate-session-logs.mjs --self-test 通过
  • 用真实的历史损坏日志(3 条未标记事件)实测:修补成功、无残留未标记事件、首帧合法、二次运行 no-op

…er#19)

Logs written by 0.1.0 and earlier carry agent-teams/* events without the
ignorable envelope marker, so the harness refuses to load those sessions
(SessionFormatUnsupportedError). Add a zero-dependency migration script
that rewrites such logs in place (idempotent, --self-test included), and
document it in the README.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[反馈] agent-teams/* 事件导致历史会话重启后无法加载:确认 0.1.0 已修复,但存量会话建议提供迁移工具

2 participants