Skip to content

feat(trajectory): D1 轨迹飞轮 — 汇聚标注 + SFT/DPO/GRPO 导出 (#50 #51) - #56

Merged
dahai80 merged 1 commit into
mainfrom
feat/d1-trajectory-flywheel
Aug 7, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/d1-trajectory-flywheel

Conversation

@dahai80

@dahai80 dahai80 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

概述

实现 D1 轨迹飞轮, 把 fusion-code 会话产生的 session jsonl 清洗为 fusion-trainer 可消费的训练数据集。

Closes #50 (统一汇聚目录 + is_error 标注)
Closes #51 (三格式导出 CLI: SFT/DPO/GRPO)

数据流

~/.fusion-code/projects/**/*.jsonl  →  collect  →  ~/.fusion/trajectories/{manifest.json, raw/*.jsonl}
                                                              ↓  export --format
                                            ~/.fusion/trajectories/{sft,dpo,grpo}.jsonl

标注规则

  • positive — 全程无 is_error=true → SFT
  • self_correction — 至少一次 tool 失败后自纠正 → DPO (rejected/chosen) + GRPO (reward=0)

CLI

fusion-code trajectory collect [--source DIR] [--dest DIR] [--product NAME]
fusion-code trajectory export  --format sft|dpo|grpo [--dest DIR] [--session ID]
fusion-code trajectory manifest [--dest DIR]
fusion-code trajectory list     [--dest DIR]

模块

  • src/services/trajectory/{types,collector,exporters,index}.ts
  • src/cli/handlers/trajectory.ts (trajectoryMain)
  • src/entrypoints/cli.tsx fast-path 注册
  • src/__tests__/trajectory/trajectory.test.ts (11 pass)
  • docs/trajectory-pipeline.md + README.md

验证

  • tsc --noEmit: clean
  • biome lint: 0 error (13 style infos)
  • bun test: 11/11 pass
  • bun run build: green
  • 端到端冒烟: collect → manifest → export sft/dpo/grpo 全通过

🤖 Generated with Claude Code

新增 trajectory 顶层子命令, 把 session jsonl 清洗为训练数据飞轮:

#50 统一汇聚 + is_error 标注:
- collector 扫描 ~/.fusion-code/projects/**/*.jsonl (含 subagents)
- 配对 tool_use ↔ tool_result, 按 is_error 标注 positive / self_correction
- 写入 ~/.fusion/trajectories/{manifest.json, raw/*.jsonl}

#51 三格式导出 CLI:
- SFT  — ShareGPT messages, 仅 positive 轨迹
- DPO  — 偏好对, self_correction: 失败作 rejected / 最终成功作 chosen
- GRPO — prompt + reward, reward = is_error ? 0 : 1

模块: src/services/trajectory/{types,collector,exporters,index}.ts
CLI:   src/cli/handlers/trajectory.ts (collect|export|manifest|list)
注册:  src/entrypoints/cli.tsx fast-path (args[0] === "trajectory")
测试:  src/__tests__/trajectory/trajectory.test.ts (11 pass)
文档:  docs/trajectory-pipeline.md + README.md

验证: tsc clean / biome lint 0 error / 11 test pass / build green / 端到端冒烟通过

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 9df3b54 into main Aug 7, 2026
1 check passed
@dahai80
dahai80 deleted the feat/d1-trajectory-flywheel branch August 7, 2026 10:02
@dahai80 dahai80 mentioned this pull request Aug 7, 2026
dahai80 added a commit that referenced this pull request Aug 30, 2026
…slice #56)

agent tool restrictions useMemo body 外移 to agentToolRestrictionsCheck.ts
(PURE-ROUTING-SUB-BLOCK useMemo-body variant, like #41-#55).
resolveAgentToolsRestrictions(ctx) returns { tools, allowedAgentTypes },
matching the literal useMemo-body shape (2 fields, not full ResolvedAgentTools).
resolveAgentTools imported directly in helper (REPL multi-use L975/L2447, kept).
useMemo thin shell remains in REPL (hook rules). byte-identical.
gates 0/921/clean/build:dev. REPL 5303→5290 (−13 net).

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant