Files
sjfhsjfh c810ea6137 feat(checker): scaffold repo-root cargo workspace + cph-diag + cph-model (WU-1)
Stand up the Rust implementation of the rule-based checker (the thing that
"stands in Lean's position" at product runtime). Single repo-wide cargo
workspace at the repo root so future components (e.g. an exporter) can reuse
shared crates.

- workspace: 6 member crates under crates/; cph-schema/cph-typst/cph-check/
  cph-cli are stubs for later WUs that compile clean today.
- cph-diag: shared diagnostic vocabulary. Severity { Warning, Error } mirrors
  Spec.Courseware.Diagnostic.Severity exactly (two-valued, no info/note — a
  contract decision documented in-code since there's no CI gate for alignment).
  Closed DiagCode set with stable string forms; Diagnostic with optional span +
  fix hint; Display renders `error[CODE]: msg / --> file:line:col / hint: …`.
- cph-model: the ADR-0008 loader. Reads manifest.toml ([project]/[info]/ordered
  [[parts]]/[targets.*]) + each part's element.toml into an ordered Lesson
  (mirrors Lean `Lesson = List (Element P)`). Structure-only: cross-checks
  part.kind == element.toml kind, rejects `..` traversal; does NOT do schema
  validation (WU-3), content-file existence (WU-3), or typst (WU-4).
  `load(root) -> (Option<Lesson>, Vec<Diagnostic>)`: Some even on collectible
  part errors, None only on hard manifest failure.
- 13 tests (7 cph-diag, 6 cph-model incl. static fixtures doubling as format
  docs). build + test + clippy -D warnings + fmt --check all green.

Judgment call flagged for review: cph-diag has no ManifestMalformed code, so
manifest-structure errors map to SchemaViolation (TODO noted in-code).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 01:27:32 +08:00

1.6 KiB

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