- root SKILL.md is her upstream file (body byte-identical to the 5fb8379c mirror; description quoted so YAML parses and Mastra can load the skill) - chat binds the whole SKILL.md plus references/product_runtime_contract.md (safety-only) instead of a ~477-character excerpt - every turn carries her full strict-workflow-router (synced to upstream) and the domain's event-judgment file; product lists follow as an extra layer - import her 10 sub-skills, family router, interpretation status contract, technique ontology and the 54 files her method names - tests/test_upstream_skill_parity.py (in the quick gate) fails whenever her skill and ours drift - 18 frontend guards that locked the excerpt design updated with 原值/新值/原因 notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
61 lines
3.0 KiB
Python
61 lines
3.0 KiB
Python
"""Reader-report and commercial Skill import contracts."""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
from scripts.report_orchestrator import render_reader_report
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_render_reader_report_defaults_to_collapsed_appendix_and_keeps_order() -> None:
|
|
rendered = render_reader_report({
|
|
"thematic_narrative": {"career": {"text": "Provided narrative"}},
|
|
"evidence_appendix": {"raw_data": {"Sun": 12.3}},
|
|
"executive_summary": {"headline": "Provided summary"},
|
|
})
|
|
assert list(rendered) == ["presentation_mode", "executive_summary", "thematic_narrative", "evidence_appendix"]
|
|
assert rendered["presentation_mode"] == "default"
|
|
assert rendered["evidence_appendix"]["expanded"] is False
|
|
|
|
|
|
def test_render_reader_report_expands_only_research_and_preserves_extensions() -> None:
|
|
rendered = render_reader_report({
|
|
"presentation_mode": "research",
|
|
"executive_summary": {"title": "Research"},
|
|
"thematic_narrative": {},
|
|
"evidence_appendix": {"raw_data": {"Moon": 3.4}},
|
|
"commercial_extension": {"health": True},
|
|
})
|
|
assert list(rendered) == [
|
|
"presentation_mode", "executive_summary", "thematic_narrative", "evidence_appendix", "commercial_extension",
|
|
]
|
|
assert rendered["evidence_appendix"]["expanded"] is True
|
|
assert rendered["commercial_extension"] == {"health": True}
|
|
|
|
|
|
def test_upstream_skill_snapshot_matches_manifest_and_root_is_her_skill() -> None:
|
|
snapshot = ROOT / "references/upstream/yinduzhanxing/SKILL.md"
|
|
manifest = json.loads((snapshot.parent / "source-manifest.json").read_text(encoding="utf-8"))
|
|
root_skill = (ROOT / "SKILL.md").read_text(encoding="utf-8")
|
|
linked_skill = ROOT / "skills/jyotish-vedic-astrology/SKILL.md"
|
|
|
|
snapshot_hash = hashlib.sha256(snapshot.read_bytes()).hexdigest()
|
|
assert snapshot_hash == manifest.get("source_skill_sha256", manifest["skill_sha256"])
|
|
assert manifest["source_mode"] == "git"
|
|
assert re.fullmatch(r"[0-9a-f]{40}", manifest["source_commit"])
|
|
assert re.fullmatch(r"[0-9a-f]{64}", manifest["source_tree_sha256"])
|
|
assert linked_skill.resolve() == (ROOT / "SKILL.md").resolve()
|
|
# 原值: 根 SKILL.md 是商业路由(含「商业运行时路由(最高优先级)」、指向上游快照、answer_policy、报告顺序),且必须与上游快照不同
|
|
# 新值: 根 SKILL.md 就是上游快照原文;产品安全规则在 references/product_runtime_contract.md
|
|
# 原因: BUG-1696 产品 2026-11-07:产品完整运行占星师 skill,不再用商业改写版替代她的方法
|
|
from tests.test_upstream_skill_parity import _split_skill
|
|
|
|
assert _split_skill(root_skill) == _split_skill(snapshot.read_text(encoding="utf-8"))
|
|
assert "## 关联技法完整调取" in root_skill
|
|
contract = (ROOT / "references/product_runtime_contract.md").read_text(encoding="utf-8")
|
|
assert "answer_policy" in contract and "interpretation_status_contract.md" in contract
|