Skip to content

【Skill治理】B 任务 Git 外壳版本治理与回滚能力#3

Open
dydpop wants to merge 6 commits into
mainfrom
governance-dev
Open

【Skill治理】B 任务 Git 外壳版本治理与回滚能力#3
dydpop wants to merge 6 commits into
mainfrom
governance-dev

Conversation

@dydpop

@dydpop dydpop commented May 3, 2026

Copy link
Copy Markdown
Collaborator

完成内容

这次 PR 是 B 任务的 Git 外壳版 Skill 治理收口。核心路线是不自研 Git-like 版本系统,而是用真实 Git 作为底层版本事实来源,SkillOS 在上面封装 Skill 语义。

已完成:

  • Git-backed Version Adapter:branch、commit、history、diff、tag、ref 文件读取。
  • Skill Snapshot / Domain Diff:稳定 JSON 快照、字段级 diff、breaking change 检测。
  • Branch / Review Workflow:Skill 修改可包装为 Git 分支、snapshot commit 和 review bundle。
  • Release Tag / Restore Commit:支持本地 lightweight release tag,回滚通过新增 restore commit 完成,不改写 Git 历史。
  • 最小 lifecycle API:暴露 snapshot、history、diff、release-tag、rollback 端点,方便后续 E 前端和 D 自管理 Agent 联调。

新增 API

全部在现有 /api/v1/lifecycle 下:

  • POST /lifecycle/{id}/snapshot
  • GET /lifecycle/{id}/snapshot/history
  • GET /lifecycle/{id}/snapshot/diff
  • POST /lifecycle/{id}/release-tag
  • POST /lifecycle/{id}/rollback

说明:rollback 只恢复 Git snapshot 文件,并创建新的 restore commit,不直接修改 Wiki 中的 live Skill 对象。

没有改动的边界

  • 未修改 docs/interfaces.md / docs/architecture.md
  • 未新增依赖。
  • 未改 E 的 frontend-dev PR。
  • 未改 D 的 agents-dev PR。
  • 未改现有 lifecycle API 字段。
  • 未 push release tag,未创建 GitHub Release。
  • 未使用 git reset --hardgit clean 或破坏性 checkout。

验证结果

已通过:

python -m compileall -q skillos\layers\skill_governance skillos\api\routes\lifecycle.py
python -m pytest tests\test_skill_governance_lifecycle_api.py -q
python -m pytest tests\test_skill_governance_git_adapter.py -q
python -m pytest tests\test_skill_governance_snapshot_diff.py -q
python -m pytest tests\test_skill_governance_branch_review.py -q
python -m pytest tests\test_skill_governance_release_rollback.py -q
python -m pytest skillos\tests\test_governance_runtime_evolution.py -q
python -m pytest skillos\tests\test_layers.py -q
git diff --check

git diff --check 只有 Windows CRLF 提示,没有空白错误。

剩余依赖 / 建议 review 重点

  • 请确认新增 Git-backed lifecycle API 是否需要同步到飞书锁定接口文档。
  • 后续 E 前端 /versions 页面可以接入这些 API 展示真实 Git-backed history / diff。
  • 后续 D 的 repair / merge / split 可以调用 snapshot API 形成可追踪版本记录。
  • 当前回滚策略是“新增恢复提交”,不是直接改 live Wiki Skill,这一点请重点确认是否符合组内预期。

@dydpop

dydpop commented May 3, 2026

Copy link
Copy Markdown
Collaborator Author

已根据自查结果补充一个小修:加固 Skill snapshot 路径生成与写入校验。

具体变化:

  • skill_id / version 作为路径组件前会做安全校验。
  • snapshot 写入前会确认目标路径仍在治理 Git 仓库内。
  • 异常路径会返回清晰错误,不会先写文件再等 Git 拦截。
  • 正常 Skill 的 snapshot 路径保持不变。

补充验证:

  • test_skill_governance_snapshot_diff.py
  • test_skill_governance_lifecycle_api.py
  • test_skill_governance_release_rollback.py
  • compileall
  • git diff --check

@dydpop dydpop marked this pull request as ready for review May 3, 2026 16:47
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.

1 participant