Files
codestable__codestable/tests/test_cs_skill_selfref.py
Wyatt Fang 30fecaae5e release(codestable): ship skill workflow v1.0.2 (#41)
收敛 CodeStable 主入口、runtime preflight、goal driver 与 skill 工程化评测闭环。

- 根 cs 对行动请求同轮直转,咨询与介绍保持非执行
- feature/issue/refactor/epic/docs 按仓库事实恢复,旧 stage skill 保留兼容薄壳
- repo-local runtime 支持版本检测、安全自动同步和显式 refresh-runtime
- 完成 Codex/Claude marketplace 1.0.2、升级文档和回归/评测证据

验证:215 tests passed;package/runtime/diff checks passed;独立 review 与 QA 无 unresolved blocking/important findings。
2026-07-10 15:23:56 +08:00

55 lines
2.2 KiB
Python
Raw Permalink 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.
"""M4 自指 + 自治eval-cs-skill 评自己(无递归)+ 实验队列 run-next 幂等。"""
from __future__ import annotations
import json
import shutil
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SCRIPTS = ROOT / ".claude/skills/eval-cs-skill/scripts"
sys.path.insert(0, str(SCRIPTS))
import runner as runner_mod # noqa: E402
import enqueue_experiment as eq # noqa: E402
# ---- 自指 ----
def test_selfref_experiment_runs(tmp_path):
exp = ROOT / "experiments/eval-cs-skill-001"
out = tmp_path / "r.json"
rc = runner_mod.main(["--experiment", str(exp), "--harness", "mock", "--k", "1", "--out", str(out)])
assert rc == 0
data = json.loads(out.read_text(encoding="utf-8"))
assert data["skill_under_test"] == "eval-cs-skill" # 指向自己
# 同一 harness/scorer 产出 measured 召回;无递归(跑完即返回)
assert data["aggregate"]["baseline"]["scores"]["recall"]["tag"] == "measured"
def test_selfref_does_not_invoke_cs_skill_tools(tmp_path):
# 自指靠「把 eval-cs-skill/SKILL.md 当被测文本注入」,不调用其工具 → 不会递归起 runner。
# 机械证据被测文本来自快照读取prompt 里含 SKILL.md 标记而非工具执行结果。
from config import ExperimentConfig, resolve_variant_text
cfg = ExperimentConfig(name="eval-cs-skill-001", skill_under_test="eval-cs-skill")
text = resolve_variant_text(cfg, "baseline", ROOT)
assert "eval-cs-skill" in text and "runner.py" in text # 是 SKILL.md 文本,不是执行产物
# ---- 自治队列 ----
def test_queue_enqueue_and_run_next(tmp_path, monkeypatch):
q = tmp_path / ".queue.jsonl"
monkeypatch.setattr(eq, "_queue_path", lambda: q)
exp = tmp_path / "exp"
shutil.copytree(ROOT / "experiments/cs-audit-001", exp,
ignore=shutil.ignore_patterns("artifacts", "iteration-*.md", "results.md"))
eq.enqueue(str(exp), "eval")
eq.enqueue(str(exp), "eval")
assert eq.run_next() == 0
assert eq._load()[0]["status"] == "done"
assert eq.run_next() == 0 # 第二个
assert all(i["status"] == "done" for i in eq._load())
assert eq.run_next() == 0 # 队列空,幂等