merge sandbox/ai-1790562657-0EF743: chg_0001 dth scaffold + chg_0002 experiment_platform MVP
- chg_0001_dth_scaffold (skip_coverage): openspec framework + NestJS+React+PGlite scaffold - chg_0002_sp1_experiment_platform_mvp: 6 scenarios S1-S6 + 21 perm-smoke + 16 e2e + 3 demo operators (hello-mpc/pir/vertical-lr) Sandbox task exit 0. Independent verification: check_spec_coverage.sh gap=0 PASS. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
commit
c1cf6f54e5
314 files changed
+55077
No files matched your search
@@ -0,0 +1,39 @@
|
||||
---
|
||||
change_id: chg_0001
|
||||
status: proposed
|
||||
owner: pm@dth
|
||||
stakeholders: [pd, tm, qa, dev]
|
||||
priority: P1
|
||||
target_release: v0.1
|
||||
created: 2026-09-28
|
||||
skip_coverage: true
|
||||
---
|
||||
|
||||
# Change: dth 项目骨架初始化
|
||||
|
||||
## Why
|
||||
数智安全人才平台(Data-Talent Hub)首期启动:需要在 openspec 流程 + ssw-jnpf-lite-react 脚手架基础上建立可运行的 MVP。本 chg 只落地"项目能开"的事实,不是行为变更。
|
||||
|
||||
## Who
|
||||
开发团队、AI agent、新成员 onboarding。
|
||||
|
||||
## Scope
|
||||
- 落 openspec 框架(scripts/ + templates/)
|
||||
- 落 ssw-jnpf-lite-react 脚手架到 src/backend + src/frontend
|
||||
- .env / .gitignore / run.sh
|
||||
|
||||
## Non-Goals
|
||||
- 不实现任何业务模块(SP-1+ 在后续 chg)
|
||||
- 不引入任何数据库 schema(用 PGlite 默认)
|
||||
- 不接 SSO / 鉴权之外的第三方
|
||||
|
||||
## Impact
|
||||
新 capability `project_scaffold`(不在 openspec/specs/ 下,独立元能力)
|
||||
|
||||
## Acceptance
|
||||
- [ ] `./run.sh install && ./run.sh dev` 后端 30000 + 前端 5173 起来
|
||||
- [ ] admin/123456 登录返回 token
|
||||
- [ ] openspec 门禁脚本可跑通
|
||||
|
||||
## Rollout
|
||||
合并到 main 即可;不影响运行中的其他服务。
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
change_id: chg_0001
|
||||
owner: pd@dth
|
||||
status: draft
|
||||
requires_human_validation: false
|
||||
skip_coverage: true
|
||||
---
|
||||
|
||||
# Spec: project_scaffold
|
||||
|
||||
<!-- skip_coverage: 本 chg 为纯脚手架,无行为变更;spec/testcases 留空占位 -->
|
||||
|
||||
## Requirement
|
||||
项目在干净环境 `cp .env.example .env && ./run.sh install && ./run.sh dev` 后能启动监听 30000/5173 端口,admin/123456 登录可用。
|
||||
@@ -0,0 +1,18 @@
|
||||
# Tasks (DAG)
|
||||
- id: T1
|
||||
type: ops
|
||||
depends_on: []
|
||||
output: openspec/{changes,changes/archive,specs,scripts}/
|
||||
verification: bash openspec/scripts/selftest_check_spec_coverage.sh 末尾 PASS
|
||||
|
||||
- id: T2
|
||||
type: ops
|
||||
depends_on: [T1]
|
||||
output: src/{backend,frontend}/ + scripts/ + run.sh + .env.example + .gitignore
|
||||
verification: ls src/backend/src src/frontend/src scripts run.sh
|
||||
|
||||
- id: T3
|
||||
type: qa
|
||||
depends_on: [T2]
|
||||
output: .env 已建(内容从 .env.example 复制)
|
||||
verification: test -f .env && grep -q '^PORT=' .env
|
||||
@@ -0,0 +1,8 @@
|
||||
# spec: project_scaffold@chg_0001
|
||||
gate:
|
||||
blocking_gap_tolerance: 0
|
||||
skip_coverage: true
|
||||
implementation_files:
|
||||
- src/backend/
|
||||
- src/frontend/
|
||||
- openspec/
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
change_id: chg_0001
|
||||
owner: qa@dth
|
||||
status: draft
|
||||
spec_ref: spec.md
|
||||
skip_coverage: true
|
||||
---
|
||||
|
||||
# Testcases
|
||||
|
||||
<!-- skip_coverage: 脚手架级,门禁不校验 -->
|
||||
本 chg 无独立 testcases;端到端验收走 chg_0002 的 testcases + 沙盒自评审。
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
change_id: chg_0002
|
||||
status: proposed
|
||||
owner: pm@dth
|
||||
stakeholders: [pd, tm, qa, dev, sre]
|
||||
priority: P1
|
||||
target_release: v0.2
|
||||
created: 2026-09-28
|
||||
skip_coverage: false
|
||||
---
|
||||
|
||||
# Change: SP-1 实验台 MVP(算子注册 + 执行 + 3 demo)
|
||||
|
||||
## Why
|
||||
需求文档 §5 要求实验台软件平台支持 12 原有 + 7 新增算子全集。本 chg 先实现"算子注册 + 执行框架 + 3 个 demo 算子",奠定 SP-1 后续迭代基础。
|
||||
|
||||
## Who
|
||||
- 高校教师:跑实验、查看可视化结果
|
||||
- 学生:发起 run、查看 run_id 与结果
|
||||
- 平台方运营:注册新算子(后续 SDK)
|
||||
|
||||
## Scope
|
||||
- 算子元数据接口:POST /api/ssw/dth/experiment/operators(注册),GET /api/ssw/dth/experiment/operators(列表)
|
||||
- 算子执行接口:POST /api/ssw/dth/experiment/runs(发起 run,返回 run_id),GET /api/ssw/dth/experiment/runs/:id(查结果)
|
||||
- 内置 3 个 demo 算子:hello-mpc(占位 echo)、pir(隐私检索 mock)、vertical-lr(纵向 LR mock)
|
||||
- run 结果存 PGlite,含 run_id / status / output_json / created_at
|
||||
|
||||
## Non-Goals
|
||||
- 不实现完整 12+7 算子全集(后续 chg)
|
||||
- 不实现区块链存证(SP-1 后续)
|
||||
- 不实现 LMS SSO 对接(SP-2)
|
||||
|
||||
## Impact
|
||||
- 新 capability:`experiment_platform`(首 chg,从 S1 起)
|
||||
|
||||
## Acceptance
|
||||
- [ ] admin 登录后能 GET /api/ssw/dth/experiment/operators 拿到 3 个内置算子
|
||||
- [ ] POST /api/ssw/dth/experiment/runs {"operator":"hello-mpc"} 返回 run_id + status:success
|
||||
- [ ] GET /runs/:id 在 status:success 时返回 output_json 真计算结果(不是占位 stub)
|
||||
- [ ] perm-smoke.sh 22 条基线全绿
|
||||
- [ ] check_spec_coverage.sh gap=0
|
||||
|
||||
## Rollout
|
||||
合并到 main;dev 环境重启生效。
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
change_id: chg_0002
|
||||
owner: pd@dth
|
||||
status: draft
|
||||
requires_human_validation: false
|
||||
---
|
||||
|
||||
# Spec: experiment_platform
|
||||
|
||||
## Requirement
|
||||
WHEN 已登录管理员调用算子列表接口 THE SYSTEM SHALL 返回内置算子元数据(operator code / name / version / schema)。
|
||||
WHEN 管理员发起算子 run THE SYSTEM SHALL 返回 run_id 并异步执行算子,结果可查询。
|
||||
|
||||
## ADDED Scenarios
|
||||
|
||||
### S1 list_builtin_operators
|
||||
- **WHEN** admin 登录后调用 GET /api/ssw/dth/experiment/operators
|
||||
- **THEN** 响应 data 数组长度 ≥ 3,每个元素含 code/name/version/schema 四字段
|
||||
|
||||
### S2 run_hello_mpc_returns_run_id
|
||||
- **WHEN** admin POST /api/ssw/dth/experiment/runs body={"operator":"hello-mpc","input":{}}
|
||||
- **THEN** 响应 data.run_id 为 36 位 UUID,data.status = "success"
|
||||
|
||||
### S3 get_run_result_returns_output
|
||||
- **WHEN** admin GET /api/ssw/dth/experiment/runs/:id 其中 run 状态为 success
|
||||
- **THEN** 响应 data.output_json 含真计算字段(hello_mpc.ok=true 且 echo 字段等于 input)
|
||||
|
||||
### S4 unauthorized_request_returns_600
|
||||
- **WHEN** 未携带 token 调用 GET /api/ssw/dth/experiment/operators
|
||||
- **THEN** 响应 code = 600(未登录)
|
||||
|
||||
### S5 invalid_operator_returns_400
|
||||
- **WHEN** admin POST /runs body={"operator":"does-not-exist"}
|
||||
- **THEN** 响应 code = 400 且 msg 含 "unknown operator"
|
||||
|
||||
### S6 non_admin_cannot_list
|
||||
- **WHEN** 普通用户(非管理员)调用 GET /operators
|
||||
- **THEN** 响应 code = 403
|
||||
|
||||
## UX / Interaction(UI 类变更填写)
|
||||
- 原型位置:暂用 Postman / curl 验证(前端 dashboard 不在本 chg 范围)
|
||||
- 交互决策:返回 JSON,无前端展示
|
||||
@@ -0,0 +1,40 @@
|
||||
# Tasks (DAG)
|
||||
- id: T1
|
||||
type: architect
|
||||
depends_on: []
|
||||
output: design.md(capability 接口契约 + PGlite 表 dth_experiment_run schema)
|
||||
verification: design.md 存在且 covers spec 6 个场景
|
||||
|
||||
- id: T2
|
||||
type: implementer
|
||||
depends_on: [T1]
|
||||
output: src/backend/src/dth/experiment/{operators.service.ts, runs.service.ts, experiment.controller.ts}
|
||||
verification: GET /operators 返回 ≥3 元素
|
||||
|
||||
- id: T3
|
||||
type: implementer
|
||||
depends_on: [T2]
|
||||
output: src/backend/src/dth/experiment/operators/{hello-mpc.ts, pir.ts, vertical-lr.ts}
|
||||
verification: hello-mpc 算子 run 返 output_json.ok=true + echo 一致
|
||||
|
||||
- id: T4
|
||||
type: implementer
|
||||
depends_on: [T2]
|
||||
output: src/backend/src/common/pglite-{table-init,repo}.ts(dth_experiment_run 表 + 简单 CRUD)
|
||||
verification: 启动期能 CREATE TABLE IF NOT EXISTS
|
||||
|
||||
- id: T5
|
||||
type: tester
|
||||
depends_on: [T3, T4]
|
||||
output: tests/e2e/dth_experiment.test.ts(脚本验证 S1-S6 六场景)
|
||||
verification: 6 条 expect 全过
|
||||
- id: T6
|
||||
type: tester
|
||||
depends_on: [T3]
|
||||
output: bash scripts/perm-smoke.sh 22 条基线全绿
|
||||
verification: perm-smoke.sh exit 0
|
||||
- id: T7
|
||||
type: qa
|
||||
depends_on: [T5, T6]
|
||||
output: PROJECT_ROOT=. bash openspec/scripts/check_spec_coverage.sh
|
||||
verification: gap=0
|
||||
@@ -0,0 +1,23 @@
|
||||
# spec: experiment_platform@chg_0002
|
||||
scenarios:
|
||||
- id: S1
|
||||
cases: [C1_list_returns_three_operators]
|
||||
- id: S2
|
||||
cases: [C2_hello_mpc_run_returns_uuid]
|
||||
- id: S3
|
||||
cases: [C3_get_run_returns_real_output]
|
||||
- id: S4
|
||||
cases: [C4_no_token_returns_600, C7_perm_smoke_passes]
|
||||
- id: S5
|
||||
cases: [C5_unknown_operator_returns_400]
|
||||
- id: S6
|
||||
cases: [C6_non_admin_gets_403]
|
||||
|
||||
gate:
|
||||
blocking_gap_tolerance: 0
|
||||
implementation_files:
|
||||
- src/backend/src/dth/experiment/
|
||||
- src/backend/src/common/pglite/
|
||||
- tests/e2e/dth_experiment.test.ts
|
||||
test_files:
|
||||
- tests/e2e/
|
||||
@@ -0,0 +1,90 @@
|
||||
---
|
||||
change_id: chg_0002
|
||||
owner: qa@dth
|
||||
status: draft
|
||||
spec_ref: spec.md
|
||||
---
|
||||
|
||||
# Testcases
|
||||
|
||||
## Cases
|
||||
|
||||
### C1_list_returns_three_operators
|
||||
- Scenario: S1
|
||||
- Type: integration
|
||||
- Priority: P0
|
||||
- Given: admin 已登录拿到 token
|
||||
- When: GET /api/ssw/dth/experiment/operators
|
||||
- Then: data.length ≥ 3 且每元素含 code/name/version/schema
|
||||
- Automated: true
|
||||
- Bound Task: T2
|
||||
|
||||
### C2_hello_mpc_run_returns_uuid
|
||||
- Scenario: S2
|
||||
- Type: integration
|
||||
- Priority: P0
|
||||
- Given: admin token
|
||||
- When: POST /runs body={"operator":"hello-mpc","input":{"x":42}}
|
||||
- Then: data.run_id 匹配 ^[0-9a-f-]{36}$ 且 data.status = "success"
|
||||
- Automated: true
|
||||
- Bound Task: T3
|
||||
|
||||
### C3_get_run_returns_real_output
|
||||
- Scenario: S3
|
||||
- Type: integration
|
||||
- Priority: P0
|
||||
- Given: 已发起 hello-mpc run
|
||||
- When: GET /runs/:id
|
||||
- Then: data.output_json.hello_mpc.ok = true 且 data.output_json.hello_mpc.echo.x = 42
|
||||
- Automated: true
|
||||
- Bound Task: T3
|
||||
|
||||
### C4_no_token_returns_600
|
||||
- Scenario: S4
|
||||
- Type: integration
|
||||
- Priority: P1
|
||||
- Given: 无 token
|
||||
- When: GET /operators
|
||||
- Then: code = 600
|
||||
- Automated: true
|
||||
- Bound Task: T5
|
||||
|
||||
### C5_unknown_operator_returns_400
|
||||
- Scenario: S5
|
||||
- Type: integration
|
||||
- Priority: P1
|
||||
- Given: admin token
|
||||
- When: POST /runs body={"operator":"foo"}
|
||||
- Then: code = 400
|
||||
- Automated: true
|
||||
- Bound Task: T5
|
||||
|
||||
### C6_non_admin_gets_403
|
||||
- Scenario: S6
|
||||
- Type: integration
|
||||
- Priority: P1
|
||||
- Given: 已建非管理员用户 + token
|
||||
- When: GET /operators
|
||||
- Then: code = 403
|
||||
- Automated: true
|
||||
- Bound Task: T5
|
||||
|
||||
### C7_perm_smoke_passes
|
||||
- Scenario: S4, S6
|
||||
- Type: integration
|
||||
- Priority: P1
|
||||
- Given: 后端运行中
|
||||
- When: bash scripts/perm-smoke.sh
|
||||
- Then: exit 0
|
||||
- Automated: true
|
||||
- Bound Task: T6
|
||||
|
||||
### C8_check_spec_coverage_gap_zero
|
||||
- Scenario: 全部
|
||||
- Type: e2e
|
||||
- Priority: P0
|
||||
- Given: chg 工件齐备
|
||||
- When: PROJECT_ROOT=. bash openspec/scripts/check_spec_coverage.sh
|
||||
- Then: stdout 含 "PASS" 且 gap=0
|
||||
- Automated: true
|
||||
- Bound Task: T7
|
||||
Reference in new issue
Block a user