Files
curriculum-project-hub/crates
sjfhsjfh ebcb3a7589 feat(model+spec): .cph-version 契约文件 + CphVersionMismatch 诊断(ADR-0016);bump 0.0.2
教研工程文件根放 .cph-version(内容=面向的 cph 版本)。cph 加载时比对自身版本
(CARGO_PKG_VERSION),不相容报 CphVersionMismatch error 并拒绝。当前判定为版本完全
相等(MVP);判定逻辑孤立在 versions_compatible 单谓词,后续可放宽为 semver 区间而
不动诊断分类/spec/CLI。

spec(7 类诊断,原 6 类):
- Diagnostic.lean: DiagKind 增 cphVersionMismatch(error 级),分类注释 6→7
- Pipeline.lean: load 阶段含 .cph-version 兼容性判定
- Courseware.lean: ADR 区间 →0016

实现:
- cph-diag: DiagCode::CphVersionMismatch("E-CPH-VERSION")
- cph-model: load() 解析 manifest 成功后 check_cph_version;versions_compatible
  谓词(完全相等);CPH_VERSION const。missing .cph-version 暂跳过(迁移期 OPEN);
  空文件报 error
- examples/TH-141、valid/mini fixture、KenKen 课各加 .cph-version=0.0.2

测试:cph-model 4 个版本门测试;全 workspace 53 passed;lake 25 jobs 绿。
负向验证:9.9.9 .cph-version → E-CPH-VERSION error + check 拒绝(exit 1)。

bump: workspace.package 0.0.1→0.0.2;cph --version 报 cph 0.0.2;README 同步
(含版本契约说明)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 16:03:54 +08:00
..

crates/

These crates implement the rule-based lesson checker that aligns to the semantic master in spec/: it reads an engineering-file (one lesson, ADR-0005) laid out per ADR-0008 (declarative manifest.toml + per-element element.toml), validates structure and content, and emits diagnostics. cph-diag (the shared diagnostic vocabulary), cph-model (the ADR-0008 loader), and cph-typst (the typst World / compile / span-mapping layer) are deliberately reusable by future components such as an exporter, which is why they live in this repo-wide crates/ directory rather than under any single component; cph-schema (kind JSON Schemas + validation), cph-check (orchestration + render-coverage) and cph-cli (the cph command-line entrypoint) are the checker proper.

Crate map

crate owner role
cph-diag WU-1 shared diagnostic vocabulary (Severity, DiagCode, Diagnostic, SourceSpan) — reusable
cph-model WU-1 parses the ADR-0008 layout into an in-memory ordered Lesson — reusable
cph-schema WU-3 the 4 stdlib kind JSON Schemas + structural validation
cph-typst WU-4 typst World, driver generation, compile, PDF, span mapping — reusable
cph-check WU-5 orchestration: render-coverage and the full check pipeline
cph-cli WU-5 the cph command-line entrypoint

Build

# from the repository root (the cargo workspace root)
cargo build      # all crates
cargo test       # cph-diag + cph-model unit/integration tests
cargo clippy --all-targets -- -D warnings
cargo fmt --check