forked from bai/curriculum-project-hub
3a50ed0ce2
- Hierarchy.lean: Platform/Organization/User struct, 三层主体层级 - User.lean: FeishuProfile, 飞书身份是绑定不是本体 - User struct: id/displayName/passwordHash/feishu - Organization.lean: OrganizationRole(owner/admin/member) + 成员管理规则 - Prelude.lean: UserId/FeishuOpenId/FeishuConnectionId 实现偏离: spec 钉 User 为独立实体, 实现 User.id 由飞书身份派生 lake build 35/35 全绿
51 lines
1.8 KiB
Lean4
51 lines
1.8 KiB
Lean4
import Spec.Prelude
|
|
import Spec.System.User
|
|
|
|
/-!
|
|
# Hierarchy —— 主体层级
|
|
|
|
整个服务中的主体: 平台 → 组织(租户)→ 用户。
|
|
|
|
- **平台**(Platform): SaaS 提供方实体
|
|
|
|
- **组织**(Organization): SaaS 租户
|
|
|
|
- **用户**(User): 租户内的独立实体
|
|
|
|
**术语**: "管理员"一词在文档中不单独出现,避免跨层歧义。
|
|
-/
|
|
|
|
namespace Spec.System
|
|
|
|
variable (I : Identifiers)
|
|
|
|
/-- 平台(`PINNED`, SaaS 提供方实体)。平台只有一个,独立于组织(租户)。平台管理
|
|
身份、会话、审计、紧急恢复等由 `PlatformAdministration`(ADR-0023)定义;本 struct 只
|
|
锚定平台在层级中的位置及其飞书应用归属。平台管理员不复用 `User` 或 org membership。 -/
|
|
structure Platform where
|
|
/-- 平台自有的飞书应用(`PINNED`, ADR-0023),用于平台管理员认证;与各 org 客户应用分离。 -/
|
|
application : I.PlatformFeishuApplicationId
|
|
|
|
/-- 组织(`PINNED`, 租户根, ADR-0020)。每个 project/team 必须归属且仅归属一个组织。
|
|
组织级角色格(owner/admin/member)、tenancy 关系、provider connection 凭据模式详见
|
|
`Spec.System.Organization`。 -/
|
|
structure Organization where
|
|
/-- 组织标识(`OPEN` 表示,ADR-0020 tenant root)。 -/
|
|
id : I.OrganizationId
|
|
|
|
/-- 用户(`PINNED`, 租户层独立实体)。必属一个组织(结构钉死)。飞书身份是绑定
|
|
不是本体,详见 `Spec.System.User`。 -/
|
|
structure User where
|
|
/-- 用户标识(`OPEN` 表示;组织内唯一,不可改;登录用)。 -/
|
|
id : I.UserId
|
|
/-- 所属组织(`PINNED`, ADR-0020)。 -/
|
|
organization : I.OrganizationId
|
|
/-- 显示名(`PINNED`, 可改)。 -/
|
|
displayName : String
|
|
/-- 密码哈希(`OPEN` 表示;id + 密码登录)。 -/
|
|
passwordHash : String
|
|
/-- 飞书绑定(`PINNED`, 可选)。 -/
|
|
feishu : Option (FeishuProfile I)
|
|
|
|
end Spec.System
|