feat(spec): build out System layer and element schema model

Picture the whole framework, then pin the element-kind language layer.

System platform layer — rebuild the semantics likec4 can't draw (ADR-0001..0004):
- Prelude: opaque Identifiers carrier (ProjectId/RunId/SessionId/Principal)
- System/Run: RunState + Terminal subset (set completeness left OPEN, no invented pending)
- System/Lock: lock owner=run (typed), LockTable exclusivity, WellFormed invariant
  (a lock holder must be a non-terminal run — couples Lock and Run)
- System/Permission: read<edit<manage role lattice, capability derivation,
  can_mono monotonicity theorem; force-release sits outside the lattice (admin-only)
- System/Audit: intentionally thin (mostly plumbing, OPEN)

Courseware product layer — split the single Lesson file into focused modules and
fix doc tautology: Primitives / Element / Lesson / Render / Diagnostic, plus
QuestionBank and Course skeletons (core relations OPEN, not invented).
Diagnostic upgrades WarnsIgnored into a severity-tagged checker rule.

Element schema + rich-content model (ADR-0006, ADR-0007):
- docs/adr/0006: kind schema is declarative JSON Schema; field types are built-in
  scalars plus a `content` extension; a `content` value is typst source taken as
  module body; rich content must carry a VirtualPath (else click-to-jump and
  relative import break — verified against typst source); import boundary =
  within the engineering file + @package
- docs/adr/0007: on-disk form is a real directory tree (agent/grep friendly);
  VirtualPath = real relative path; layout conventions deferred
- spec/Courseware/RichContent: prose anchor for rich content (opaque VPath,
  RichContentRef); ElementData kept abstract — JSON/typst internals are
  implementation detail, not contract

lake build green (18 jobs), no sorry, toolchain v4.31.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-22 00:31:14 +08:00
parent 4a828e07b9
commit f1dce07789
18 changed files with 740 additions and 107 deletions
+20 -3
View File
@@ -1,9 +1,26 @@
import Spec.Courseware.Primitives
import Spec.Courseware.RichContent
import Spec.Courseware.Element
import Spec.Courseware.Lesson
import Spec.Courseware.Render
import Spec.Courseware.Diagnostic
import Spec.Courseware.QuestionBank
import Spec.Courseware.Course
/-!
# Courseware —— 产品层契约(课程工程文件)
本层是护城河:课程"工程文件"的语义母本与合法性规则。当前只有 lesson 骨架
(见 `Spec.Courseware.Lesson`,ADR-0005);题库、course 编排、完整合法性判定
等仍 `OPEN`,待各自 ADR 落定后逐个加入。
护城河:课程"工程文件"的语义母本与合法性规则。决策出处 ADR-0005 / 0006 / 0007。
已填实(PINNED):
- `Primitives` —— 基元载体(表示留给实现;schema 形态见 ADR-0006)。
- `RichContent` —— 富内容 = 带虚拟路径的 typst 源(ADR-0006 的 prose 母本)。
- `Element` —— kind 标签 + 依赖 schema 的数据。
- `Lesson` —— element 的有序序列(序载教学语义、不建模时长)。
- `Render` —— (kind × target) 渲染配置矩阵 + covers。
- `Diagnostic` —— Severity + checker 第一条诊断(缺渲染 ⇒ warning)。
留白骨架(核心关系 OPEN,已 surface 不臆造):
- `QuestionBank` —— 题库与 element 的关系(引用 vs 内联)。
- `Course` —— course = lesson 编排的规则。
-/