forked from EduCraft/curriculum-project-hub
f1dce07789
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>
46 lines
1.7 KiB
Lean4
46 lines
1.7 KiB
Lean4
import Spec.Courseware.Lesson
|
|
import Spec.Courseware.Render
|
|
|
|
/-!
|
|
# Diagnostic —— checker 诊断(种子)
|
|
|
|
产品里"站在 Lean 位置"的那个 rule-based checker,语义在此沉淀。它对 lesson 提诊断,
|
|
每条诊断有**严重级别**。本模块固定级别类型,并落第一条规则——ADR-0005 钉死的"缺
|
|
渲染 ⇒ warning"。完整的"合法 lesson"判定仍 OPEN,本模块只是它的起点。
|
|
-/
|
|
|
|
namespace Spec.Courseware
|
|
|
|
/--
|
|
诊断的严重级别(`PINNED` 二分, ADR-0005 区分 warning 与阻断)。
|
|
|
|
`error` 阻断(产物不合法),`warning` 不阻断(产物仍可导出,只是有损/有忽略)。
|
|
ADR-0005 已用到这个区分:缺渲染是 warning 而非 error。更细的级别(info/hint)未
|
|
决策,故只二分。
|
|
-/
|
|
inductive Severity where
|
|
| warning
|
|
| error
|
|
|
|
variable (P : Primitives)
|
|
|
|
/--
|
|
**缺渲染诊断**:lesson 在 target `t` 下存在无法渲染的 element(`PINNED`, ADR-0005)。
|
|
|
|
成立 ⟺ 存在某 element,其 kind 在 `t` 下未配渲染规则。这条对应 checker 的第一条
|
|
诊断;其级别由下面的 `renderIgnoredSeverity` 钉死为 **warning**。
|
|
-/
|
|
def renderIgnored (l : Lesson P) (c : RenderConfig P) (t : P.TargetId) : Prop :=
|
|
∃ e ∈ l, ¬ c.covers e.kind t
|
|
|
|
/--
|
|
缺渲染诊断的级别 = **warning**(`PINNED`, ADR-0005,**非 error**)。
|
|
|
|
ADR-0005 明确:某 (kind, target) 无渲染规则时,checker 报 warning 说该 element 在
|
|
该 target 被忽略,**不阻断导出**。把这条决策固定为一个常量,使"它是 warning 不是
|
|
error"成为契约里可被引用、可被对齐的事实,而不是散落在 prose 里的口头约定。
|
|
-/
|
|
def renderIgnoredSeverity : Severity := .warning
|
|
|
|
end Spec.Courseware
|