chg_0012(T4): gate gap=0 + 5 回归 + 1 新 全 PASS
- openspec 5 件套完整(proposal/spec/tasks/testcases/testcases.map.yaml) - check_spec_coverage.sh: 10 scenarios / 10 cases OK, gap=0 - tsc backend: 0 新错(仅预存 chg_0002 vertical-lr.ts:52) - tsc frontend: 0 错 - 9 e2e 套件 PASS (DTH_BASE=127.0.0.1:30051): - chg_0002 (16) + chg_0005 (27) + chg_0006 (17) + chg_0007 (33) - chg_0008 (15) + chg_0009 (27) + chg_0010 (37) + chg_0011 (24) - chg_0012 (45 sub-assertion / 10 case) - 报告落 /tmp/chg_0012-qa.log 5 回归 + 1 新 = 6 套(brief 要求):chg_0006 + chg_0008 + chg_0009 + chg_0010 + chg_0011 + chg_0012 ✓ 加固跑了 chg_0002 / chg_0005 / chg_0007 也全 PASS — chg_0012 改动未触及 19 算子/auth/books/shop Co-Authored-By: Claude <[email protected]>
This commit is contained in:
1 parent
8cf00ea00a
commit
78feb39316
5 files changed
+396
No files matched your search
@@ -0,0 +1,88 @@
|
||||
---
|
||||
change_id: chg_0012
|
||||
status: proposed
|
||||
owner: pm@dth
|
||||
stakeholders: [pd, tm, qa, dev]
|
||||
priority: P1
|
||||
target_release: v0.8
|
||||
created: 2026-09-29
|
||||
skip_coverage: false
|
||||
---
|
||||
|
||||
# chg_0012 lms_multiscene_v2 — LMS v2 多场景课程平台
|
||||
|
||||
## Why
|
||||
|
||||
chg_0006 LMS v1(学员 + 课程 + 选课)已落地,但课程是"扁平"资源 — 只描述
|
||||
课程元信息(代码 / 学分 / 教师),不描述课程**怎么上**。教学场景里每门课
|
||||
应该是**有序 scene 序列**(讲解 → 测验 → 仿真 → PBL),学员按顺序完成并
|
||||
留进度。
|
||||
|
||||
chg_0010 / chg_0011 已用 e2e 跑通"业务场景测试 = 算子协同"模式,但**没有一个
|
||||
"教学编排层"把场景化的算子协同封装成可复用课程**。本 chg 把 LMS 升级到 v2,
|
||||
引入 4 类 scene(slide / quiz / simulation / pbl),同时落地 **FRC 6-scene
|
||||
模板**把 chg_0010 的 6 步联合风控流程以"可执行 simulation"形式嵌入 LMS 课程。
|
||||
|
||||
## What
|
||||
|
||||
**做**:
|
||||
|
||||
1. **场景设计文档** `docs/dth/lms-v2/scenario.md`:4 类 scene 的设计原则 + payload
|
||||
schema 表 + MiniMD 5 节点规格 + FRC 模板字段表 + 与 OpenMAIC 的对位
|
||||
(保留 dth 命名 `simulation` 而非 OpenMAIC 的 `interactive`,理由:chg_0010/0011
|
||||
已落地"6 步 simulation 流程"作为术语)。
|
||||
|
||||
2. **后端 LMS v2 扩展**(在 chg_0006 v1 之上增量):
|
||||
- 新表 `lms_course_scene`:id, course_id FK, scene_type enum
|
||||
(slide|quiz|simulation|pbl), payload_json TEXT, order_index INT
|
||||
- `lms_enrollment` 加列 `progress_scene_ids JSONB`(append-only 幂等)
|
||||
- `lms-v2.service.ts`:createCourseWithScenes / renderScene / gradeQuiz /
|
||||
completeScene / createFromFrcTemplate + MiniMD(5 节点 + 非法节点原样保留)
|
||||
- `lms-v2.controller.ts`:6 endpoints
|
||||
- `lms.module.ts`:注册 v2 controller + service
|
||||
|
||||
3. **FRC 6-scene 模板** `POST /courses/from-frc-template {course_code,teacher}`:
|
||||
6 个 simulation scene(order_index 1-6),embed_url 严格对位 chg_0010 S1-S6
|
||||
(did-tds / psi / paillier / threshold / abac / audit)。
|
||||
|
||||
4. **前端 LMS v2**(4 组件 + 3 视图):
|
||||
- `CourseList.tsx` / `CourseDetail.tsx` / `SceneRenderer.tsx`
|
||||
- `SlideScene.tsx` / `QuizScene.tsx` / `SimScene.tsx` / `PBLScene.tsx`
|
||||
- 注册 `/lms` 路径
|
||||
|
||||
5. **e2e 测试** `tests/e2e/dth_lms_v2.test.sh`:10 case 覆盖 S1-S10。
|
||||
|
||||
6. **门禁更新** `openspec/scripts/check_spec_coverage.sh`:无需改动
|
||||
(5 件套天然 cover)。
|
||||
|
||||
**约束**:
|
||||
|
||||
- 0 新算子 / 0 新依赖 / 0 前端框架切换。
|
||||
- LMS v1 schema / seed 不动(chg_0006 e2e 不回归)。
|
||||
- MiniMD 自实现(h1/h2/p/ul/li/code 5 节点 + 非法节点原样保留)— 零新依赖。
|
||||
- 不动 src/backend/src/dth/experiment/operators/(19 算子已实现)。
|
||||
- 不动 src/backend/src/auth/、books/、shop/(红线)。
|
||||
|
||||
**关键不变量**:
|
||||
|
||||
| 不变量 | 失败码 | 文案 |
|
||||
|---|---|---|
|
||||
| 重复 `course_code` | 409 | DUPLICATE_COURSE_CODE |
|
||||
| 重复 enroll | 409 | ALREADY_ENROLLED(与 v1 一致)|
|
||||
| 非法 `scene_type`(如 video)| 422 | INVALID_SCENE_TYPE |
|
||||
| simulation.embed_url 非 http(s):// | 400 | INVALID_EMBED_URL |
|
||||
| PBL render | 501 | NOT_IMPLEMENTED + 占位文案 |
|
||||
| progress_scene_ids append-only | — | 重复 complete 不增 count |
|
||||
|
||||
## Acceptance
|
||||
|
||||
- 10 case e2e 全 PASS(chg_0012 自身)
|
||||
- 5 回归 e2e 全 PASS(chg_0006/0008/0009/0010/0011)
|
||||
- gate `PROJECT_ROOT=. bash openspec/scripts/check_spec_coverage.sh` gap=0
|
||||
- `tsc --noEmit` 0 error(除预存 chg_0002 vertical-lr.ts:52)
|
||||
- 文档 `docs/dth/lms-v2/scenario.md` 含 4 scene payload schema + MiniMD 规格 + FRC 模板字段表
|
||||
|
||||
## 与 handoff §2 的对应
|
||||
|
||||
chg_0009 重派 ✅ → chg_0010 FRC 设计 ✅ → chg_0011 VC 设计 ✅ → 本 chg
|
||||
"LMS 教学编排层" = handoff 教学场景闭环。
|
||||
@@ -0,0 +1,87 @@
|
||||
# Spec: lms_v2
|
||||
|
||||
## Requirement
|
||||
|
||||
THE SYSTEM SHALL provide a multi-scene LMS v2 platform where each course is an
|
||||
**ordered scene sequence** of 4 types (slide / quiz / simulation / pbl),
|
||||
with append-only progress tracking and a built-in FRC 6-scene template that
|
||||
maps chg_0010's 6-step federated risk control flow into embeddable iframe
|
||||
scenes, so that 业务方能把"算子协同 + 教学编排"封装成可复用课程 WITHOUT
|
||||
introducing new operators / endpoints / dependencies.
|
||||
|
||||
## ADDED Scenarios
|
||||
|
||||
### S1 LMS v1 数据模型基础
|
||||
|
||||
- **WHEN** admin GET /api/ssw/dth/lms/students
|
||||
- **THEN** 响应 data 数组长度 ≥ 2,含固定 seed UUID `11111111-1111-1111-1111-111111111111`
|
||||
- **AND** schema 含 id / student_no / name / email / created_at
|
||||
- **AND** admin GET /api/ssw/dth/lms/courses 同样 ≥ 2 + schema 含 code / credits / instructor
|
||||
|
||||
### S2 多场景数据模型 v2
|
||||
|
||||
- **WHEN** admin GET /api/ssw/dth/lms-v2/courses/:id/scenes
|
||||
- **THEN** 响应 code = 200(lms_course_scene 表存在)
|
||||
- **AND** admin POST /lms-v2/courses with `scene_type="video"` → 422 INVALID_SCENE_TYPE(CHECK 约束拒绝)
|
||||
|
||||
### S3 创建多场景课程
|
||||
|
||||
- **WHEN** admin POST /lms-v2/courses with code + name + scenes[{slide,quiz}]
|
||||
- **THEN** 回 200 + course + 2 scenes(按 order_index 升序)
|
||||
- **AND** 重复 code → 409 DUPLICATE_COURSE_CODE
|
||||
- **AND** admin POST /lms-v2/courses/from-frc-template → 回 200 + course + 6 simulation scenes
|
||||
|
||||
### S4 选课 + 进度 append-only 幂等
|
||||
|
||||
- **WHEN** admin POST /lms/courses/:courseId/enroll with student_id
|
||||
- **THEN** 回 200,lms_enrollment 记录建立(progress_scene_ids = [])
|
||||
- **AND** POST /lms-v2/scenes/:sceneId/complete with student_id + course_id → progress_count = 1
|
||||
- **AND** 再次 complete 同一 scene → progress_count 仍 = 1(append-only 幂等)
|
||||
- **AND** complete 不同 scene → progress_count = 2
|
||||
|
||||
### S5 SlideScene Markdown 渲染(MiniMD 5 节点)
|
||||
|
||||
- **WHEN** slide payload 含 markdown:`# Title\n## Sub\n- a\n- b\nnormal\n\`\`\`\ncode\n\`\`\`\nillegal`
|
||||
- **THEN** GET /lms-v2/courses/:courseId/scenes/:sceneId/render 返回 html:
|
||||
`<h1>Title</h1><h2>Sub</h2><ul><li>a</li><li>b</li></ul><p>normal</p><pre><code>code</code></pre><p>illegal</p>`
|
||||
- **AND** "illegal" 节点作为 `<p>` 原样保留(非 5 类节点不抛错、不删字符)
|
||||
|
||||
### S6 QuizScene 判分
|
||||
|
||||
- **WHEN** quiz 含 choice 题(answer="2")+ short 题(keywords=["私有不泄露","交集"])
|
||||
- **THEN** grade(answers={q1:"2"}) → score=1.0(choice 全对)
|
||||
- **AND** grade(answers={q1:"1"}) → score=0.0(choice 全错)
|
||||
- **AND** grade(answers={qs1:"PSI 求交集"}) → score=1.0(1/2 关键词命中 = 50% ≥ 满分)
|
||||
- **AND** grade(answers={qs1:"完全不相关"}) → score=0.0(0 关键词命中)
|
||||
|
||||
### S7 SimScene iframe + embed_url 校验
|
||||
|
||||
- **WHEN** admin POST /lms-v2/courses with simulation scene + embed_url="https://example.com/embed"
|
||||
- **THEN** 回 200
|
||||
- **AND** GET /render → 回 embed_url 字段 = "https://example.com/embed"
|
||||
- **AND** admin POST with embed_url="javascript:alert(1)" → 400 INVALID_EMBED_URL(非 http(s):// 前缀)
|
||||
|
||||
### S8 FRC 6-scene 模板(严格对位 chg_0010 S1-S6)
|
||||
|
||||
- **WHEN** admin POST /lms-v2/courses/from-frc-template with course_code + teacher
|
||||
- **THEN** 创建 1 门课程 + 6 simulation scenes
|
||||
- **AND** order_index 严格 = 1,2,3,4,5,6
|
||||
- **AND** 6 embed_url 严格对位:
|
||||
- s1: did-tds
|
||||
- s2: psi
|
||||
- s3: paillier
|
||||
- s4: threshold
|
||||
- s5: abac
|
||||
- s6: audit
|
||||
|
||||
### S9 E2E 完整流程
|
||||
|
||||
- **WHEN** admin login → from-frc-template → student login → enroll → 6 render + 6 complete
|
||||
- **THEN** 每个 scene 的 complete 回 200
|
||||
- **AND** 最终 progress_count = 6 / 6 = 1.0
|
||||
|
||||
### S10 PBL 占位一致性
|
||||
|
||||
- **WHEN** admin POST /lms-v2/courses with scene_type="pbl"
|
||||
- **THEN** GET /render 回 code=501 NOT_IMPLEMENTED + msg="PBL 场景 v2 实现,当前仅作课程占位"
|
||||
- **AND** 前端 PBLScene.tsx 占位文案 "PBL 场景 v2 实现,当前仅作课程占位" 与后端 501 文案字面一致
|
||||
@@ -0,0 +1,72 @@
|
||||
# Tasks (DAG)
|
||||
|
||||
- id: T1
|
||||
type: architect
|
||||
depends_on: []
|
||||
output: docs/dth/lms-v2/scenario.md
|
||||
verification:
|
||||
- 4 类 scene payload schema 表
|
||||
- MiniMD 5 节点规格 (h1/h2/p/ul/li/code) + 原样保留非法节点
|
||||
- FRC 模板字段表(6 scene + embed_url 对位)
|
||||
- 与 OpenMAIC 对位(保留 simulation 命名)
|
||||
- 关键不变量 6 条
|
||||
|
||||
- id: T2
|
||||
type: implementer
|
||||
depends_on: [T1]
|
||||
output: |
|
||||
src/backend/src/lms/lms-v2.controller.ts (6 endpoints)
|
||||
src/backend/src/lms/lms-v2.service.ts (5 service methods + MiniMD)
|
||||
src/backend/src/common/pglite/init.ts (lms_course_scene 表 + progress_scene_ids 列)
|
||||
src/backend/src/lms/lms.module.ts (注册 v2 controller + service)
|
||||
src/frontend/src/api/lms/client.ts (8 API helpers)
|
||||
src/frontend/src/views/LMS/{CourseList,CourseDetail,SceneRenderer,SlideScene,QuizScene,SimScene,PBLScene}.tsx
|
||||
src/frontend/src/App.tsx (注册 /lms 3 个路由)
|
||||
tests/e2e/dth_lms_v2.test.sh (10 case e2e)
|
||||
verification:
|
||||
- 0 新算子 / 0 新依赖 / 0 前端框架切换
|
||||
- 6 不变量:409 / 422 / 400 / 501 / append-only / scene_type enum CHECK
|
||||
- FRC 6 scene embed_url 严格对位 chg_0010 S1-S6
|
||||
- 10 case e2e 覆盖 S1-S10
|
||||
- 复用既有 helpers(json_get / assert / login)
|
||||
|
||||
- id: T3
|
||||
type: tester
|
||||
depends_on: [T2]
|
||||
output: |
|
||||
1 次完整 e2e 跑通(bash tests/e2e/dth_lms_v2.test.sh 10/0)
|
||||
verification:
|
||||
- pass=10 case, fail=0
|
||||
- 含 4+ 不变性断言(slide 渲染 / quiz 判分 / append-only / FRC 对位)
|
||||
- 含 1 拒绝路径(非法 embed_url → 400)
|
||||
- 含 1 完整 E2E 串联(C9)
|
||||
|
||||
- id: T4
|
||||
type: qa
|
||||
depends_on: [T3]
|
||||
output: |
|
||||
PROJECT_ROOT=. bash openspec/scripts/check_spec_coverage.sh
|
||||
6 e2e 套件全跑(chg_0006/0008/0009/0010/0011/0012)
|
||||
verification:
|
||||
- gate gap = 0
|
||||
- tsc --noEmit 0 error(除预存 chg_0002 vertical-lr.ts:52)
|
||||
- 5 回归 + 1 新 = 6 e2e 套件全 PASS
|
||||
- 报告落 /tmp/chg_0012-qa.log
|
||||
|
||||
- id: T5
|
||||
type: pm
|
||||
depends_on: [T4]
|
||||
output: |
|
||||
openspec/changes/chg_0012_lms_multiscene_v2/.xstudio-report.md
|
||||
verification:
|
||||
- 报告含 改动文件清单 + 门禁结果 + 是否建议合并
|
||||
- 报告大小 ≥ 30 行
|
||||
- chg_0012 任务全部完成
|
||||
|
||||
# Notes
|
||||
|
||||
- LMS v1 schema / seed 不动(chg_0006 e2e 不回归);v2 在 v1 之上增量扩展
|
||||
- LMS 路径在 src/backend/src/lms/(CLAUDE.md F-2 索引 dth/lms/ 是错的;以在盘为准)
|
||||
- backend 测试端口 30051(PGlite 数据放 /tmp/lmsv2-pglite)
|
||||
- 提交顺序:T1 (docs) → T2 (impl) → T3 (e2e) → T4 (gate) → T5 (pm)
|
||||
- 与 chg_0006 的边界:v1 controllers/services 不动,v2 是新加 module import
|
||||
@@ -0,0 +1,65 @@
|
||||
# spec: lms_v2@chg_0012
|
||||
scenarios:
|
||||
- id: S1
|
||||
cases: [C1_lms_v1_data_model_basic]
|
||||
- id: S2
|
||||
cases: [C2_multiscene_v2_data_model]
|
||||
- id: S3
|
||||
cases: [C3_create_multi_scene_course]
|
||||
- id: S4
|
||||
cases: [C4_enroll_and_progress_append_only]
|
||||
- id: S5
|
||||
cases: [C5_slide_markdown_render]
|
||||
- id: S6
|
||||
cases: [C6_quiz_grading]
|
||||
- id: S7
|
||||
cases: [C7_sim_iframe_embed_url]
|
||||
- id: S8
|
||||
cases: [C8_frc_6_scene_template]
|
||||
- id: S9
|
||||
cases: [C9_e2e_full_flow]
|
||||
- id: S10
|
||||
cases: [C10_pbl_placeholder_consistency]
|
||||
gate:
|
||||
blocking_gap_tolerance: 0
|
||||
implementation_files:
|
||||
- src/backend/src/lms/lms-v2.controller.ts
|
||||
- src/backend/src/lms/lms-v2.service.ts
|
||||
- src/backend/src/common/pglite/init.ts
|
||||
- src/backend/src/lms/lms.module.ts
|
||||
- src/frontend/src/api/lms/client.ts
|
||||
- src/frontend/src/views/LMS/CourseList.tsx
|
||||
- src/frontend/src/views/LMS/CourseDetail.tsx
|
||||
- src/frontend/src/views/LMS/SceneRenderer.tsx
|
||||
- src/frontend/src/views/LMS/SlideScene.tsx
|
||||
- src/frontend/src/views/LMS/QuizScene.tsx
|
||||
- src/frontend/src/views/LMS/SimScene.tsx
|
||||
- src/frontend/src/views/LMS/PBLScene.tsx
|
||||
- src/frontend/src/App.tsx
|
||||
- docs/dth/lms-v2/scenario.md
|
||||
test_files:
|
||||
- tests/e2e/dth_lms_v2.test.sh
|
||||
notes:
|
||||
reuses_operators_no_new_code: true
|
||||
operator_coverage: "0 of 19 chg_0002/0008/0009 operators (none used; LMS v2 only orchestrates)"
|
||||
scenario_count: 10
|
||||
invariant_assertions: 6
|
||||
duplicates_course_code_invariant: 409
|
||||
duplicate_enroll_invariant: 409
|
||||
append_only_progress: true
|
||||
illegal_scene_type_invariant: 422
|
||||
bad_embed_url_invariant: 400
|
||||
pbl_not_implemented: 501
|
||||
scene_type_enum_values:
|
||||
- slide
|
||||
- quiz
|
||||
- simulation
|
||||
- pbl
|
||||
frc_template_scene_count: 6
|
||||
frc_embed_url_keywords:
|
||||
- did-tds
|
||||
- psi
|
||||
- paillier
|
||||
- threshold
|
||||
- abac
|
||||
- audit
|
||||
@@ -0,0 +1,84 @@
|
||||
# Testcases: chg_0012_lms_multiscene_v2
|
||||
|
||||
Each case asserts one specific scenario from spec.md via the e2e shell script
|
||||
`tests/e2e/dth_lms_v2.test.sh`. The script reuses `json_get` / `assert` / `login`
|
||||
helpers from chg_0006/0010/0011.
|
||||
|
||||
## S1 LMS v1 数据模型基础
|
||||
|
||||
- **C1_lms_v1_data_model_basic**
|
||||
- GET /api/ssw/dth/lms/students → ≥ 2 students, schema complete, seed UUID present
|
||||
- GET /api/ssw/dth/lms/courses → ≥ 2 courses, schema complete, seed UUID present
|
||||
|
||||
## S2 多场景数据模型 v2
|
||||
|
||||
- **C2_multiscene_v2_data_model**
|
||||
- GET /api/ssw/dth/lms-v2/courses/:id/scenes → code 200 (lms_course_scene table exists)
|
||||
- POST with scene_type="video" → 422 INVALID_SCENE_TYPE (CHECK constraint rejects)
|
||||
|
||||
## S3 创建多场景课程
|
||||
|
||||
- **C3_create_multi_scene_course**
|
||||
- admin POST /lms-v2/courses with code + scenes[slide,quiz] → 200 + 2 scenes
|
||||
- duplicate code → 409 DUPLICATE_COURSE_CODE
|
||||
- admin POST /lms-v2/courses/from-frc-template → 200 + 6 simulation scenes
|
||||
|
||||
## S4 选课 + 进度 append-only 幂等
|
||||
|
||||
- **C4_enroll_and_progress_append_only**
|
||||
- enroll → 200
|
||||
- complete scene 1 → progress_count = 1
|
||||
- complete scene 1 again → progress_count still 1 (idempotent)
|
||||
- complete scene 2 → progress_count = 2
|
||||
|
||||
## S5 SlideScene Markdown 渲染(MiniMD 5 节点)
|
||||
|
||||
- **C5_slide_markdown_render**
|
||||
- render slide scene → 200
|
||||
- html contains: `<h1>`, `<h2>`, `<ul>`, 2× `<li>`, `<p>normal`, `<code>code-block-here`
|
||||
- "illegal_node_blah" preserved verbatim (rendered as `<p>`)
|
||||
|
||||
## S6 QuizScene 判分
|
||||
|
||||
- **C6_quiz_grading**
|
||||
- perfect choice → score = 1.0
|
||||
- wrong choice → score = 0.0
|
||||
- 50% keyword hit (1/2) → score = 1.0
|
||||
- 0% keyword hit → score = 0.0
|
||||
|
||||
## S7 SimScene iframe + embed_url 校验
|
||||
|
||||
- **C7_sim_iframe_embed_url**
|
||||
- create with https URL → 200
|
||||
- render → embed_url matches
|
||||
- create with `javascript:` URL → 400 INVALID_EMBED_URL
|
||||
|
||||
## S8 FRC 6-scene 模板(严格对位 chg_0010 S1-S6)
|
||||
|
||||
- **C8_frc_6_scene_template**
|
||||
- from-frc-template → 6 scenes, all type=simulation
|
||||
- order_index strictly 1,2,3,4,5,6
|
||||
- 6 embed_url keywords present (did-tds, psi, paillier, threshold, abac, audit)
|
||||
|
||||
## S9 E2E 完整流程
|
||||
|
||||
- **C9_e2e_full_flow**
|
||||
- admin login → from-frc-template → student login → enroll
|
||||
- 6 render calls all 200
|
||||
- 6 complete calls all 200
|
||||
- final progress_count = 6, progress_pct = 1.0
|
||||
|
||||
## S10 PBL 占位一致性
|
||||
|
||||
- **C10_pbl_placeholder_consistency**
|
||||
- create with scene_type="pbl" → 200
|
||||
- render → code = 501 NOT_IMPLEMENTED
|
||||
- backend msg = "PBL 场景 v2 实现,当前仅作课程占位"
|
||||
- frontend PBLScene.tsx constant = same string (drift detector)
|
||||
|
||||
## all test_runner_and_gate_pass
|
||||
|
||||
- **C11_test_runner_passes_all** — bash tests/e2e/dth_lms_v2.test.sh exit 0
|
||||
- **C12_check_spec_coverage_gap_zero** — bash openspec/scripts/check_spec_coverage.sh gap=0
|
||||
|
||||
Total: 12 cases, 45 sub-assertions.
|
||||
Reference in new issue
Block a user