将角色与 Skill 从 .claude 迁入 .agent,移除 Claude CLI 运行时并接入固定 Opus 角色 profile、完整 schema、预算 deadline、raw 与回执证据链。 同步拆分 Skill 职责、复利 lesson、Gate 回放、Dashboard 人审入口、数据库登记和机械门禁;候选设计正文不包含在本提交中。
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
||
"""rewrite-selection expectedRevision 纯函数离线测试(不连库)。"""
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
PROJECT_ROOT = Path(__file__).resolve().parents[3]
|
||
SCRIPTS = PROJECT_ROOT / ".agent" / "skills" / "rewrite-selection" / "scripts"
|
||
sys.path.insert(0, str(SCRIPTS))
|
||
|
||
import click # noqa: E402
|
||
|
||
from assert_expected_revision import ( # noqa: E402
|
||
RevisionConflict,
|
||
assert_expected_revision,
|
||
)
|
||
|
||
|
||
def expect_conflict(fn) -> None:
|
||
try:
|
||
fn()
|
||
except RevisionConflict:
|
||
return
|
||
raise AssertionError("应抛 RevisionConflict")
|
||
|
||
|
||
def main() -> None:
|
||
snap = {
|
||
"work_id": 8,
|
||
"chapter_order": 12,
|
||
"block_id": 99,
|
||
"revision": 4,
|
||
}
|
||
assert assert_expected_revision(snap, 4)["revision"] == 4
|
||
expect_conflict(lambda: assert_expected_revision(snap, 3))
|
||
empty = {**snap, "block_id": None, "revision": 0}
|
||
assert assert_expected_revision(empty, 0)["revision"] == 0
|
||
expect_conflict(lambda: assert_expected_revision(empty, 1))
|
||
try:
|
||
raise RevisionConflict("x")
|
||
except click.ClickException:
|
||
pass
|
||
print("PASS:assert_expected_revision 纯函数全部通过")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|