M0-meta-schema.yaml
18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# M0 全域元数据校验根规范 (v2.0)
# 全域本体校验根规范,新增React前端模板JSON Schema约束;统一前后端数据、组件、页面描述标准。
meta_model:
version: "2.0"
$schema: https://json-schema.org/draft/2020-12/schema
definitions:
# 基础通用标识类型
Identifier:
type: string
pattern: "^[a-z][a-zA-Z0-9]*$"
description: 小写驼峰字段/组件标识
UpperIdentifier:
type: string
pattern: "^[A-Z][a-zA-Z0-9]*$"
description: 大写驼峰聚合/命令/事件ID
NonEmptyString:
type: string
minLength: 1
SceneId:
type: string
pattern: "^SCENE_[A-Z0-9_]+$"
RuleId:
type: string
pattern: "^R_[A-Z0-9_]+$"
TopicName:
type: string
pattern: "^topic_[a-z0-9_]+$"
ConsistencyTypeEnum:
type: string
enum: [strong, eventual]
DbEngineEnum:
type: string
enum: [mysql8]
AuthModeEnum:
type: string
enum: [oauth2_jwt]
# ========== M8前端专用枚举(新增) ==========
FrontTemplateTypeEnum:
type: string
enum: [single_table_form, master_detail_form, custom_drag_form]
description: single_table_form单实体表单;master_detail_form主从表单;custom_drag_form自定义空白拖拽模板
FrontComponentEnum:
type: string
enum: [input, number_input, date_picker, switch, table, card, text_area, select]
description: React底层原子拖拽组件
BindSourceTypeEnum:
type: string
enum: [aggregate_root, aggregate_entity]
description: 组件绑定数据源类型:聚合根/聚合内部子实体
ReactRenderModeEnum:
type: string
enum: [form_modal, page_container, drawer]
description: 页面渲染载体:弹窗/整页/侧边抽屉
# M1 领域模型单元定义
M1_Attribute:
type: object
required: [name, type]
properties:
name: { $ref: "#/definitions/Identifier" }
type:
type: string
enum: [string, int, decimal, datetime, boolean]
refAggregate: { type: string }
refRoot: { type: string }
refIdentifier: { type: string }
description: { type: string }
M1_Relation:
type: object
required: [ref, relationType]
properties:
ref: { $ref: "#/definitions/NonEmptyString" }
relationType:
type: string
enum: [composition]
M1_Entity:
type: object
required: [name, localIdentifier, attributes]
properties:
name: { $ref: "#/definitions/NonEmptyString" }
localIdentifier: { $ref: "#/definitions/Identifier" }
attributes:
type: array
items: { $ref: "#/definitions/M1_Attribute" }
M1_AggregateRoot:
type: object
required: [name, identifier, attributes]
properties:
name: { $ref: "#/definitions/NonEmptyString" }
identifier: { $ref: "#/definitions/Identifier" }
attributes:
type: array
items: { $ref: "#/definitions/M1_Attribute" }
relations:
type: array
items: { $ref: "#/definitions/M1_Relation" }
M1_Aggregate:
type: object
required: [aggregateId, description, aggregateRoot]
properties:
aggregateId:
type: string
pattern: "^[A-Z][a-zA-Z]+Aggregate$"
description: { $ref: "#/definitions/NonEmptyString" }
aggregateRoot: { $ref: "#/definitions/M1_AggregateRoot" }
entities:
type: array
items: { $ref: "#/definitions/M1_Entity" }
valueObjects:
type: array
maxItems: 0
# M2 命令行为单元定义
M2_InputParam:
type: object
required: [name, type]
properties:
name: { $ref: "#/definitions/Identifier" }
type: { type: string }
optional: { type: boolean }
# bizSteps 单步:一段“闭指令集”程序的一条。CommandEngine 逐条通用解释执行。
# ★ 闭集合的意义:AI 转换命令行为时 type 只能取下列枚举之一——越界值在模型校验层即被拒,
# 引擎面被封顶(仅需实现这些 opcode),AI 产物可静态校验。
M2_BizStep:
type: object
required: [instruction]
properties:
stepNo: { type: integer }
desc: { type: string }
instruction:
type: object
required: [type]
properties:
type:
type: string
# 数据/落库 opcode + 控制流/跨聚合写回 opcode(IF 携带 then/else 嵌套指令,类比 M4 condition,
# 使命令级 bizSteps 也具备判断分支能力;REMOTE_SET_FIELD/REMOTE_INCREMENT_FIELD 通用回写被引用聚合字段)
enum: [LOAD_AGGREGATE, SET_FIELD, AUTO_FILL_FIELD, REMOTE_QUERY_SET_FIELD,
CONDITION_SET_FIELD, CALL_OTHER_COMMAND, COMMIT_TRANSACTION,
IF, REMOTE_SET_FIELD, REMOTE_INCREMENT_FIELD]
params: { type: object }
M2_Command:
type: object
required: [cmdId, desc, inputParams, validations, emitEvents]
properties:
cmdId: { $ref: "#/definitions/UpperIdentifier" }
desc: { $ref: "#/definitions/NonEmptyString" }
inputParams:
type: array
items: { $ref: "#/definitions/M2_InputParam" }
validations:
type: array
items: { type: string }
# 命令行为:闭指令集程序(首选);或旧的自然语言描述字符串(向后兼容,引擎按 commandType 合成默认程序)
bizSteps:
oneOf:
- type: string
- type: array
items: { $ref: "#/definitions/M2_BizStep" }
emitEvents:
type: array
items: { $ref: "#/definitions/UpperIdentifier" }
sideEffect: { type: string }
M2_AggregateBehavior:
type: object
required: [aggregateId, aggregateRoot, commands]
properties:
aggregateId:
type: string
pattern: "^[A-Z][a-zA-Z]+Aggregate$"
aggregateRoot: { $ref: "#/definitions/NonEmptyString" }
commands:
type: array
items: { $ref: "#/definitions/M2_Command" }
# ME 事件模型单元定义
ME_Event:
type: object
required: [topic, payload]
properties:
topic: { $ref: "#/definitions/TopicName" }
payload:
type: array
items: { $ref: "#/definitions/Identifier" }
consumers:
type: array
items: { type: string }
ME_OutboxConfig:
type: object
required: [enabled, table]
properties:
enabled: { type: boolean }
table: { $ref: "#/definitions/NonEmptyString" }
pollInterval: { type: string }
batchSize: { type: integer, minimum: 1 }
cleanupDays: { type: integer, minimum: 1 }
ME_CrossConsistencyRule:
type: object
required: [triggerEvent, targetAggregate, targetCommand, consistencyType]
properties:
triggerEvent: { $ref: "#/definitions/UpperIdentifier" }
targetAggregate:
type: string
pattern: "^[A-Z][a-zA-Z]+Aggregate$"
targetCommand: { $ref: "#/definitions/UpperIdentifier" }
consistencyType: { $ref: "#/definitions/ConsistencyTypeEnum" }
# M3 存储部署映射单元定义
M3_TableMapping:
type: object
required: [domainEntity, table, pk, fieldMap]
properties:
domainEntity: { $ref: "#/definitions/NonEmptyString" }
table: { $ref: "#/definitions/NonEmptyString" }
pk: { $ref: "#/definitions/Identifier" }
shardRule: { type: string }
fieldMap:
type: object
additionalProperties: { type: string }
M3_AggregateDeploy:
type: object
required: [aggregateId, serviceName, commandApi, tableMappings]
properties:
aggregateId:
type: string
pattern: "^[A-Z][a-zA-Z]+Aggregate$"
serviceName:
type: string
pattern: "^[a-z-]+-service$"
commandApi:
type: object
additionalProperties:
type: string
pattern: "^/api/v1/.+"
tableMappings:
type: array
items: { $ref: "#/definitions/M3_TableMapping" }
# M4 业务场景编排单元定义(Saga 编排步骤)
# stepType 全集按职责分组;引擎(CommandEngine)对每种类型做"模型驱动的通用解释",
# 不含任何具体聚合/字段字面量。所有非 stepType 的属性均为可选,按步骤类型取用。
M4_SceneStep:
type: object
required: [stepType]
properties:
stepType:
type: string
enum:
# —— 起止 ——
- start # 显式起点(可标注触发方式)
- return # 正常结束并返回结果
- end # 正常结束(return 的别名)
- errorEnd # 异常结束,抛出 message
# —— 数据/校验/派生 ——
- readOnlyCheck # 校验 bindAggregate 引用存在
- validate # 独立执行 M8 必填 + M1 类型/约束校验
- derive # 独立执行 M2 derivations 服务端重算
- assign # 按表达式给字段赋值
- transform # 数据转换(assign 的语义别名)
- script # 求值一段表达式,可写回字段
# —— 命令/事件(EDA) ——
- bindCommand # 绑定并执行某聚合的 M2 命令
- callScene # 调用子场景(嵌套编排/复用)
- callService # 调用外部系统/API
- emitEvent # 显式发布领域事件
- waitEvent # 等待某外部事件到达
# —— 控制流 ——
- condition # 排他分支(if/else)
- switch # 多路分支
- parallel # 并行网关(多分支汇合)
- while # 条件循环
- loopItems # 遍历某子实体集合(foreach)
# —— Saga/可靠性 ——
- retry # 带重试的子步骤
- compensate # 逆序执行已登记的补偿
- timer # 定时/延时/超时
- userTask # 人工任务/审批网关
# 命令绑定(bindCommand)
bindAggregate: { type: string }
bindCommand: { $ref: "#/definitions/UpperIdentifier" }
# Saga 补偿:bindCommand 成功后登记的逆向命令,失败时逆序触发
compensateAggregate: { type: string }
compensateCommand: { $ref: "#/definitions/UpperIdentifier" }
# 控制流:条件/循环谓词、switch 分派表达式与分支
when: { type: string } # condition/while 的布尔表达式
switchOn: { type: string } # switch 的分派表达式(避开 YAML 保留字 on/off)
then: # condition 为真的子步骤
type: array
items: { $ref: "#/definitions/M4_SceneStep" }
else: # condition 为假的子步骤
type: array
items: { $ref: "#/definitions/M4_SceneStep" }
body: # while/loopItems/retry 的子步骤
type: array
items: { $ref: "#/definitions/M4_SceneStep" }
cases: # switch 分支列表
type: array
items:
type: object
properties:
equals: { type: string }
steps:
type: array
items: { $ref: "#/definitions/M4_SceneStep" }
default: # switch 兜底子步骤
type: array
items: { $ref: "#/definitions/M4_SceneStep" }
branches: # parallel 并行分支
type: array
items:
type: object
properties:
steps:
type: array
items: { $ref: "#/definitions/M4_SceneStep" }
itemsFrom: { type: string } # loopItems 遍历的子实体名
maxIterations: { type: integer }# while/loopItems 迭代上限(防失控)
maxAttempts: { type: integer } # retry 最大尝试次数
# 数据步骤:assign/transform/script
assignments: # assign/transform 的赋值列表
type: array
items:
type: object
required: [targetField, expression]
properties:
targetField: { type: string }
expression: { type: string }
targetField: { type: string } # assign 单字段简写
expression: { type: string } # assign 简写/script 表达式
assignTo: { type: string } # script 结果写回字段
# 事件步骤:emitEvent/waitEvent/timer
emitEvent: { $ref: "#/definitions/UpperIdentifier" }
waitEvent: { $ref: "#/definitions/UpperIdentifier" }
timeoutMs: { type: integer }
delayMs: { type: integer }
# 人工任务:userTask
assignee: { type: string }
role: { type: string }
approveParam: { type: string } # 入参中表示"已审批"的字段名(true 放行)
# 外部调用:callService / 子场景:callScene
callScene: { $ref: "#/definitions/SceneId" }
serviceRef: { type: string }
endpoint: { type: string }
method: { type: string }
# 通用:起点触发方式 / 异常结束消息
triggerType: { type: string }
message: { type: string }
M4_Scene:
type: object
required: [sceneId, sceneName, aggregateScope, permissionBind, flowSteps]
properties:
sceneId: { $ref: "#/definitions/SceneId" }
sceneName: { $ref: "#/definitions/NonEmptyString" }
aggregateScope:
type: array
items:
type: string
pattern: "^[A-Z][a-zA-Z]+Aggregate$"
permissionBind:
type: array
items: { $ref: "#/definitions/Identifier" }
flowSteps:
type: array
items: { $ref: "#/definitions/M4_SceneStep" }
# M5 安全权限单元定义
M5_SecurityRoot:
type: object
required: [globalConfig, principals, functionPermissions, maskRules, encryptRules]
# M6 监控告警单元定义
M6_Alert:
type: object
required: [desc, level, trigger]
properties:
desc: { type: string }
level:
type: string
enum: [严重告警, 警告告警]
trigger: { type: string }
M6_MonitorRoot:
type: object
required: [globalConfig, serviceMetricBind, alertRules]
# M7 流量SLA单元定义
M7_QualityRoot:
type: object
required: [aggregateSla, commandSla, sceneSla, flowControl]
# MetaRule 动态业务规则单元定义
MetaRule_Param:
type: object
required: [paramId, name, dataType, defaultValue]
MetaRule_Item:
type: object
required: [ruleId, ruleVersion, ruleName, matchCondition, effect, message]
properties:
ruleId: { $ref: "#/definitions/RuleId" }
effect:
type: string
enum: [REJECT, ALERT, SKIP_CHECK, CALC_FILL, COMPENSATE]
MetaRule_Group:
type: object
required: [groupId, groupType, bindScene, rules]
# ===================== M8 前端拖拽模板完整定义(新增核心) =====================
M8_FrontFieldBind:
type: object
required: [bindAggregateId, bindSourceType, domainFieldName]
properties:
bindAggregateId:
type: string
pattern: "^[A-Z][a-zA-Z]+Aggregate$"
bindSourceType: { $ref: "#/definitions/BindSourceTypeEnum" }
domainEntityName: { type: string }
domainFieldName: { $ref: "#/definitions/Identifier" }
formLabel: { type: string }
placeholder: { type: string }
required: { type: boolean }
maskField: { type: boolean }
M8_FrontDragComponent:
type: object
required: [compId, compType, fieldBind]
properties:
compId: { $ref: "#/definitions/Identifier" }
compType: { $ref: "#/definitions/FrontComponentEnum" }
width: { type: string }
span: { type: integer }
fieldBind: { $ref: "#/definitions/M8_FrontFieldBind" }
childComponents:
type: array
items: { $ref: "#/definitions/M8_FrontDragComponent" }
M8_FrontPageTemplate:
type: object
required: [templateId, templateName, templateType, renderMode, bindSceneId, rootComponents]
properties:
templateId: { $ref: "#/definitions/Identifier" }
templateName: { $ref: "#/definitions/NonEmptyString" }
templateType: { $ref: "#/definitions/FrontTemplateTypeEnum" }
renderMode: { $ref: "#/definitions/ReactRenderModeEnum" }
bindSceneId: { $ref: "#/definitions/SceneId" }
masterAggregate: { type: string }
detailAggregates:
type: array
items: { type: string }
rootComponents:
type: array
items: { $ref: "#/definitions/M8_FrontDragComponent" }
M8_FrontSchema:
type: object
required: [reactGlobalConfig, pageTemplates]
properties:
reactGlobalConfig:
type: object
required: [uiLib, dragEngineStorage]
properties:
uiLib:
type: string
const: antd
dragEngineStorage:
type: string
const: mysql8
pageTemplates:
type: array
items: { $ref: "#/definitions/M8_FrontPageTemplate" }
# 各分层根Schema定义(新增M8根校验)
M1_Schema:
type: object
required: [aggregates, globalConstraints]
M2_Schema:
type: object
required: [behaviors, globalBehaviorConstraints]
ME_Schema:
type: object
required: [eventModel]
M3_Schema:
type: object
required: [deploymentMappings]
M4_Schema:
type: object
required: [sceneModel]
M5_Schema:
type: object
required: [securityModel]
M6_Schema:
type: object
required: [monitorModel]
M7_Schema:
type: object
required: [qualityModel]
MetaRule_Schema:
type: object
required: [metaRuleModel]
M8_Schema:
type: object
required: [frontModel]
rootAllOntologySchema:
type: object
oneOf:
- { $ref: "#/definitions/M1_Schema" }
- { $ref: "#/definitions/M2_Schema" }
- { $ref: "#/definitions/ME_Schema" }
- { $ref: "#/definitions/M3_Schema" }
- { $ref: "#/definitions/M4_Schema" }
- { $ref: "#/definitions/M5_Schema" }
- { $ref: "#/definitions/M6_Schema" }
- { $ref: "#/definitions/M7_Schema" }
- { $ref: "#/definitions/MetaRule_Schema" }
- { $ref: "#/definitions/M8_Schema" }