from __future__ import annotations from decode_content.contracts import ( BUSINESS_STAGES, CREATION_STAGES, DIM_ATTRIBUTE_BY_TYPE, KNOWLEDGE_TYPES, SCOPE_TYPES, WHAT_KINDS, compute_contract_hash, iter_contract_snapshots, load_decode_contracts, ) def test_load_decode_contracts_covers_skill_prompts_and_cache(): contract = load_decode_contracts() assert "判颗" in contract.phase1 assert "作用域" in contract.phase2 assert "payload" in contract.phase3.lower() assert contract.schema_for_particle_type("how")["$id"] == "ingest-payload-how.schema.json" assert any(src["relative_path"].startswith("prompts/") for src in contract.prompt_sources()) assert contract.scope_tree_sources() assert len(contract.content_hash) == 64 assert compute_contract_hash(contract) == contract.content_hash def test_contract_constants_record_formal_business_terms(): assert KNOWLEDGE_TYPES == ("how", "what", "why") assert BUSINESS_STAGES == ("灵感", "选题", "脚本") assert CREATION_STAGES == ("定向", "构思", "结构", "成文", "打磨") assert WHAT_KINDS == ("子集", "多维关系", "序列") assert SCOPE_TYPES == ("substance", "form", "feeling", "effect", "intent") assert DIM_ATTRIBUTE_BY_TYPE == {"how": "how工序", "what": "what构成", "why": "why原理"} def test_contract_snapshots_can_feed_repository(): snapshots = iter_contract_snapshots() assert snapshots[0].contract_name == "创作知识提取-skill" assert snapshots[0].contract_type == "skill" assert snapshots[0].content_hash and len(snapshots[0].content_hash) == 64 assert snapshots[0].snapshot["constants"]["dim_attribute_by_type"]["how"] == "how工序" assert any(s.contract_type == "prompt_phase" for s in snapshots) assert any(s.contract_type == "schema" for s in snapshots) assert any(s.contract_type == "prompt" for s in snapshots)