Rule Operation Classification System Design
I. Core Understanding
Rules are used in two key stages:
- Assembling Prompts: Instructing the LLM on what to generate, how to generate it, and what constraints exist.
- Assembling AML: After the front-end receives the JSON from the LLM, it corrects, completes, and validates it according to rules to generate valid AML.
II. Operation Types and Rule Mapping
add (Create)
| Rule Category | Prompt Usage | AML Assembly Usage |
|---|
| required (Mandatory) | Instruct LLM it must be generated | validateProperties check |
| validation (Validation) | Instruct LLM on format requirements | sanitizeProperties correction |
| pattern (Regex) | Instruct LLM on matching rules | validateProperties check |
| auto_generate (Numbering) | Instruct LLM to skip this field | Sequence API auto-generation |
| field_default (Default Value) | Instruct LLM it can be omitted | sanitizeProperties population |
| auto_create (Auto-create Relationship) | Instruct LLM not needed | Pre-create nested Item |
| permission (Permission) | Instruct LLM who can create | Front-end permission check |
| lifecycle (Lifecycle) | Instruct LLM on initial state | Set state in AML |
| workflow (Workflow) | Instruct LLM to trigger a process | Auto-start after creation |
edit (Repair/Optimize)
| Rule Category | Prompt Usage | AML Assembly Usage |
|---|
| validation | Instruct LLM that modified values must be valid | sanitizeProperties correction |
| pattern | Same as above | validateProperties check |
| permission | Tells LLM who can modify | Frontend permission check |
| lifecycle_transition | Tells LLM what transitions are allowed from the current state | State transition validation |
| calculation | Tells LLM the calculation rule | Automatically calculates field values |
| required | Tells LLM which fields cannot be cleared | validateProperties check |
get (retrieve/query)
| Rule Category | Prompt Purpose | AML Assembly Purpose |
|---|
| keyed (key field) | Tells LLM what to use for querying | Builds AML query conditions |
| permission | Tells LLM who can view | Query permission filtering |
| relationship | Tells LLM which relationships to fetch | Builds AML query depth |
| lifecycle | Tells LLM to filter by state | AML where condition |
III. Relationship Handling Rules
During creation (add)
- Relationship with create_related=1: Automatically creates related object when the main object is created.
- Relationship with related_notnull=1: The related object must exist.
- Relationship with is_dependent=1: The related object's lifecycle depends on the main object.
- Behavior float: The related object can exist independently.
- Behavior part: The related object is part of the main object.
During query (get)
- is_list_type=1: One-to-many relationship, use getRelatedItems when querying.
- auto_search=1: Automatically searches for related objects.
During editing (edit)
- Cascading update: Which fields of the related object need to be synchronized when the main object's attributes are modified.
- State propagation: Whether the related object's state changes when the main object's state changes.
IV. Organization of Rules in Prompts
Layered by operation type:
基础层(所有操作共享):对象定义、属性列表、数据类型
操作层(按add/edit/get区分):
add:创建规则、编号规则、必填规则、关系创建规则、初始状态
edit:修改规则、状态转换规则、计算规则、级联规则
get:查询规则、键字段、关系带出规则、权限过滤规则
业务层(按业务系统区分):
特定业务约束、特殊逻辑