规则库 3.8.1 + 排盘修复 + 评测体系

- 规则库 3.6→3.8.1(542→548 条):剪枝上锁、R-杂-38 从格临界双轨、
  R-事-10~13 冲刑方向判别、R-禁-23 自造必要条件之禁
- 排盘修复随 3.6.2 已发:港澳时区夏令时双向误拨、晚子时双重换日
- 新增 评测/ 目录(BaziQA 题答分离、判分工具、记分卡、with/without-skill 对照)
  与 scripts/query_rules.py 条款检索;ZIPEC_EVAL 评测额度豁免
- manifest 重建并重新签名;VERSION 保持 3.6.2,不发版不打 tag
This commit is contained in:
2026-10-13 12:34:36 +08:00
parent b20fd5c3c9
commit 1a0eed1999
338 changed files with 36533 additions and 30 deletions
+48
View File
@@ -10,6 +10,12 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
import _license_gate as gate
@pytest.fixture(autouse=True)
def _no_eval_env(monkeypatch):
"""默认清掉评测豁免变量,保证既有用例覆盖的是未豁免口径。"""
monkeypatch.delenv("ZIPEC_EVAL", raising=False)
@pytest.fixture
def root(tmp_path):
return tmp_path
@@ -161,3 +167,45 @@ class TestGrantUses:
st = json.loads((root / "data" / ".license.json").read_text("utf-8"))
assert st["remaining_uses"] == 12
assert gate.check(root) is None
class TestEvalExemption:
"""ZIPEC_EVAL=1:评测复测豁免——直接放行,不签发、不扣次、不创建任何文件。"""
def test_no_license_passes_and_creates_nothing(self, root, monkeypatch):
monkeypatch.setenv("ZIPEC_EVAL", "1")
assert gate.check(root) is None
gate.consume(root)
assert not (root / "data").exists()
def test_public_marker_not_issued(self, root, monkeypatch):
make_public_marker(root)
monkeypatch.setenv("ZIPEC_EVAL", "1")
assert gate.check(root) is None
assert not (root / "data" / ".license.json").exists() # 不就地签发
def test_licensed_copy_not_decremented(self, root, monkeypatch):
make_state(root)
before = (root / "data" / ".license.json").read_text("utf-8")
monkeypatch.setenv("ZIPEC_EVAL", "1")
assert gate.check(root) is None
gate.consume(root)
st = json.loads((root / "data" / ".license.json").read_text("utf-8"))
assert st["remaining_uses"] == 2 # 不扣次
assert (root / "data" / ".license.json").read_text("utf-8") == before
def test_exhausted_copy_passes_under_eval(self, root, monkeypatch):
make_state(root, max_uses=0)
monkeypatch.setenv("ZIPEC_EVAL", "1")
assert gate.check(root) is None
def test_env_unset_keeps_original_behavior(self, root, monkeypatch):
monkeypatch.setenv("ZIPEC_EVAL", "0") # 仅认 "1",其他值不豁免
make_public_marker(root)
assert gate.check(root) is None
assert (root / "data" / ".license.json").exists() # 公众版仍首启签发
def test_env_unset_exhausted_copy_still_denied(self, root, monkeypatch):
monkeypatch.setenv("ZIPEC_EVAL", "0")
make_state(root, max_uses=0)
assert "次数已用尽" in gate.check(root)