BossAgents Six Capability Enhancements — Requirements Specification Document
Version: v1.0 | Date: 2026-06-25 | Based on In-depth Audit and Analysis of Six Capabilities
1. Component Positioning
1.1 Core Responsibilities
This component is responsible for enhancing the rule-driven depth and relationship-aware breadth of BossAgents CapabilityRuntime's six capabilities (identify, create, repair, optimize, compare, generate), achieving a capability leap from "LLM fallback" to "rule-driven + relationship-aware".
1.2 Core Inputs
- User Business Requests: Capability requests (identify/create/repair/optimize/compare/generate) dispatched via CapabilityDispatcher.
- Rule Engine Context: Rule definitions and condition data from the sciot_rules_v2 table and built-in rules.
- SCSAI Object Data: Industrial object attribute and relationship data queried from/written to the SCSAI Agent platform.
- Template Data: Generation template definitions from the prompt_templates table.
- Relationship Discovery Requests: Relationship identification/discovery calls from RelationshipCapability and RelationshipResolver.
1.3 Core Outputs
- Capability Execution Results: Structured responses containing rule hits, LLM fallback, repair actions, and optimization suggestions.
- SCSAI AML Instructions: AML operation instructions (including Relationships nodes) submitted to the SCSAI Agent.
- Relationship Discovery Results: Associated object information returned from identification queries.
- Optimization Execution Results: Change confirmations after auto_fix type rules are automatically submitted to SCSAI.
- Rule Hit Statistics: Rule execution history records and hit rate data.
1.4 Responsibility Boundaries
- Not Responsible For: LLM Router model selection and fallback chain scheduling (SmartLLMRouter's responsibility).
- Not Responsible For: Digital employee task orchestration and collaboration chain scheduling (LiteScheduler's responsibility).
- Not Responsible For: Storage and Retrieval of Memory System (MemoryService Responsibility)
- Not Responsible For: Front-end Interaction and Message Channels (Channel Responsibility)
- Not Responsible For: Database Schema Design and Migration (Infrastructure Responsibility)
2. Domain Terminology
Six Capabilities
: Six core business capabilities provided by CapabilityRuntime: identify (identify/query), create (create), repair (repair), optimize (optimize), compare (compare), generate (generate).
Rule Engine
: A business rule execution engine based on the sciot_rules_v2 table-driven approach, supporting rule matching and action execution across multiple scopes (IDENTIFY/CREATE/CREATE_PRE/CREATE_POST/REPAIR/OPTIMIZE/COMPARE/GENERATE/TRANSFORM/INSPECT).
EARS
: Easy Approach to Requirements Syntax, a requirements syntax specification that uses keywords like When/While/If/Where to structurally describe system behavior.
AML
: SCSAI Markup Language, an XML-based operation language for the SCSAI Agent platform, used for CRUD operations and relationship manipulation on objects.
Relationships Node
: An XML fragment within AML that describes associations between objects, with the format ...
Relation Discovery
: Automatically identifies the associations that should be established between objects via RelationshipCapability.identifyRelations() and RelationshipResolver.discoverRelations().
Fallback Path
: The capability execution path that falls back to the LLM Router for intelligent processing when the Rule Engine cannot handle a request.
Built-in Rules
: Default rules hardcoded in _loadBuiltinRules(), serving as a supplement and fallback to database rules.
auto_fix
: One of the rule action types, indicating that after a rule match, a fix is automatically executed and submitted to SCSAI, as opposed to the 'suggest' type which only returns recommendations.
create_post
: A rule scope executed after object creation, used to perform supplementary operations (such as relationship creation, number completion, etc.) after SCSAI creation succeeds.
prompt_templates
: A database table storing prompt templates, which can be referenced by generate/transform scope rules to enable templated generation.
3. Roles and Boundaries
3.1 Core Roles
- Business User: Initiates business requests via IM/Web/Mini Programs, triggering the execution of the six core capabilities.
- System Administrator: Manages rule configurations, template definitions, and relationship type mappings.
3.2 External Systems
- SCSAI Agent: Industrial object storage and relationship management platform, the ultimate data destination for the six capabilities.
- SmartLLMRouter: LLM scheduling service, the handler when the rule engine is downgraded.
- CapabilityDispatcher: Unified scheduling entry point, routes user requests to the CapabilityRuntime.
- MemoryService: Memory service, providing user profiles and historical context for capability execution.
3.3 Interaction Context
@startuml
left to right direction
actor "业务用户" as user
rectangle "BossAgents 六大能力增强" as core {
usecase "CapabilityRuntime\n(identify/create/repair/\noptimize/compare/generate)" as rt
}
system "SCSAI Agent" as SCSAI
system "SmartLLMRouter" as llm
system "RelationshipCapability\n+ RelationshipResolver" as rel
system "CapabilityDispatcher" as disp
user --> disp : 业务请求
disp --> rt : 能力调度
rt --> SCSAI : AML操作(含Relationships)
rt --> llm : 规则未命中时降级
rt --> rel : 关系发现/Identify
rel --> SCSAI : 关系查询
@enduml
4. DFX约束
4.1 性能
- 规则引擎单次匹配响应时间 SHALL 不超过 50ms(内置规则路径)
- LLM 降级路径响应时间 SHALL 不超过 5s(含 SmartLLMRouter 调度)
- 关系发现集成后 identify 能力总响应时间增量 SHALL 不超过 500ms
4.2 可靠性
- 规则引擎与 LLM 双路降级 SHALL 保证至少一路可用,不允许同时失败
- auto_fix 类型规则自动提交 SCSAI 失败时 SHALL 回滚并记录审计日志
- Relationships 节点生成失败 SHALL 不影响主对象属性的创建/修改
4.3 安全性
- auto_fix 规则自动提交 SCSAI 前 SHALL 通过权限校验
- 规则 action_script 执行 SHALL 在安全沙箱(vm.createContext)中运行
- 关系发现结果 SHALL 不泄露跨租户的对象信息
4.4 可维护性
- 新增内置规则 SHALL 遵循现有
_loadBuiltinRules()的注册模式 - 规则命中统计 SHALL 实时更新
sciot_rules_v2.hit_count和last_hit_at - 能力增强的变更 SHALL 记录到
sciot_rule_history表
4.5 兼容性
- 新增内置规则 SHALL 不破坏现有数据库规则的执行优先级
- AMLGenerator 输出格式变更 SHALL 与 AMLBuilder 保持一致
- identify 能力集成关系发现 SHALL 保持现有无关系返回的兼容性
5. 核心能力
5.1 generate 能力规则驱动增强(P0-1)
5.1.1 业务规则
- generate 内置规则注册:系统 SHALL 为 GENERATE scope 注册内置规则,实现基于模板的规则驱动生成。
a. 验收条件:When 用户调用 generate 能力且规则引擎可用,the RuleEngine SHALL 匹配 GENERATE scope 内置规则并返回模板化生成结果。
- transform built-in rule registration: The system SHALL register built-in rules for the TRANSFORM scope to enable rule-driven processing of data conversion.
a. Acceptance criteria: When a user invokes the generate capability and specifies a transform operation, the RuleEngine SHALL match the built-in rules for the TRANSFORM scope and return the conversion result.
- Templated generation: The generate rule SHALL reference templates from the prompt_templates table, associated via the prompt_template_id field.
a. Acceptance criteria: When a generate rule is configured with a prompt_template_id, the RuleEngine SHALL load the template from the prompt_templates table, populate variables, and use it as the generation instruction.
- Complex object-specific rules: The system SHALL register dedicated generate rules for complex ItemTypes such as ECO, BOM, and Document.
a. Acceptance criteria: When a user requests to generate an ECO-type object, the RuleEngine SHALL match the dedicated ECO generate rule and return a structured generation template.
- Prohibition: Generate rules SHALL NOT directly hardcode the generated content; they must be implemented via templates or action_script.
a. Acceptance criteria: When auditing built-in generate rules, each rule SHALL reference a prompt_template_id or contain an action_script, rather than hardcoding the output.
5.1.2 Interaction Flow
@startuml
actor "用户" as user
participant "CapabilityRuntime" as rt
participant "RuleEngine" as re
database "prompt_templates" as pt
participant "SmartLLMRouter" as llm
participant "SCSAI" as SCSAI
user -> rt : generate(item_type, data)
rt -> re : executeGenerate(context)
re -> re : 匹配 GENERATE scope 规则
alt 规则命中
re -> pt : 加载 prompt_template
pt --> re : 模板内容
re -> re : 填充模板变量
re --> rt : 模板化生成结果
else 规则未命中
re --> rt : executed=false
rt -> llm : LLM降级生成
llm --> rt : LLM生成结果
end
rt --> user : 生成结果
@enduml
5.1.3 异常场景
- 模板不存在
a. 触发条件:generate 规则引用的 prompt_template_id 在 prompt_templates 表中不存在
b. System behavior: Skip this rule and continue matching the next rule.
c. User perception: No perception; fallback to LLM generation.
- Missing template variables
a. Trigger condition: Variables referenced in the template do not exist in the context.
b. System behavior: Replace missing variables with empty strings and log a WARNING.
c. User perception: Corresponding variable positions in the generated result are empty.
- No generate rules matched
a. Trigger condition: No rules match within the GENERATE scope.
b. System behavior: Fallback to SmartLLMRouter.
c. User perception: Return LLM-generated result, with source marked as llm_router.
5.2 AMLGenerator Relationships Support (P0-2)
5.2.1 Business Rules
- Relationships node output: AMLGenerator._buildAML() SHALL include the node when generating AML.
a. Acceptance Condition: When the input data contains a relationships field, the AMLGenerator SHALL include the
- Relationship Item Format: Each relationship item in the Relationships node SHALL conform to the SCSAI AML standard, containing type, action, and relevant attributes.
a. Acceptance Condition: When generating AML containing relationships, each Relationship Item SHALL include a type attribute, an action attribute, and necessary attribute fields.
- Consistency with AMLBuilder: The Relationships output format of the AMLGenerator SHALL be consistent with the AMLBuilder.
a. Acceptance Condition: When generating AML from the same set of relationship data using AMLGenerator and AMLBuilder respectively, the structure of the Relationships node SHALL be completely identical.
- Empty Relationship Compatibility: When the input data does not contain a relationships field or contains an empty array, the AMLGenerator SHALL not output the
node.
a. Acceptance Condition: When the input data has no relationship information, the generated AML SHALL not contain the
- Relationship Preservation in Degradation Path: When the LLM degrades to create an object, relationship data SHALL be correctly output to SCSAI via the AMLGenerator.
a. Acceptance Condition: When CapabilityRuntime.create() degrades to the LLM path and the context contains relationship data, the AMLGenerator SHALL include the Relationships node in the AML.
5.2.2 Interaction Flow
@startuml
actor "CapabilityRuntime" as rt
participant "AMLGenerator" as gen
participant "SCSAI" as SCSAI
rt -> gen : _buildAML(data, schema, options)
gen -> gen : 构建属性 XML
gen -> gen : 检查 data.relationships
alt 存在关系数据
gen -> gen : 构建 Relationships XML
gen -> gen : 合并属性+关系
else 无关系数据
gen -> gen : 仅输出属性 XML
end
gen --> rt : 完整 AML(含/不含 Relationships)
rt -> SCSAI : applyAML(aml)
SCSAI --> rt : 操作结果
@enduml
5.2.3 异常场景
- 关系项缺少必要字段
a. 触发条件:relationships 数组中的某个关系项缺少 type 或 action 字段
b. System Behavior: Skip that relationship item, log a WARNING, and continue processing other relationship items.
c. User Perception: Some relationships were not created, with skip records in the log.
- The referenced object of the relationship item does not exist.
a. Trigger Condition: The object referenced by related_id in the relationship item does not exist in SCSAI.
b. System Behavior: SCSAI returns an error; AMLGenerator logs the error but does not interrupt the creation of the main object.
c. User Perception: The main object is created successfully, but some relationships fail to be created. The returned result includes error messages for the failed relationship creation.
5.3 Identify Capability Integration Relationship Discovery (P0-3)
5.3.1 Business Rules
- Relationship Discovery Integration: CapabilityRuntime.identify() SHALL call RelationshipCapability.identifyRelations() during identification queries to obtain association information.
a. Acceptance Criteria: When a user performs an identify query and the query returns object data, the CapabilityRuntime SHALL also call identifyRelations() and attach the relationship information to the returned result.
- Relationship Information Attachment Format: The identify return result SHALL contain a related_objects field, storing the results of relationship discovery.
a. Acceptance Criteria: When the identify query is successful and relationship discovery returns results, the response SHALL include a related_objects array, where each element contains the fields relationship_type, related_item, and direction.
- Relationship Discovery Failure Does Not Affect Main Query: When the call to RelationshipCapability.identifyRelations() fails, it SHALL NOT affect the return of the main identify query results.
a. Acceptance Criteria: When identifyRelations() throws an exception, the identify query SHALL return the main results normally, the related_objects field shall be an empty array, and the reason for the relationship discovery failure shall be logged.
- Relationship discovery optional control: The identify method SHALL support controlling whether to perform relationship discovery via the options.includeRelations parameter.
a. Acceptance criteria: When identify is called with includeRelations: false, the CapabilityRuntime SHALL skip relationship discovery calls.
- Relationship discovery performance constraint: Relationship discovery calls SHALL have a timeout limit to avoid prolonged blocking of the main query.
a. Acceptance criteria: When identifyRelations() execution exceeds 2 seconds, the CapabilityRuntime SHALL cancel relationship discovery and return the main results.
5.3.2 Interaction Flow
@startuml
actor "用户" as user
participant "CapabilityRuntime" as rt
participant "RuleEngine" as re
participant "RelationshipCapability" as rc
participant "SmartLLMRouter" as llm
user -> rt : identify(context, options)
rt -> re : executeIdentify(context)
re --> rt : 识别结果
rt -> rc : identifyRelations(item_type, item_data)
rc --> rt : 关联对象列表
alt 关系发现成功
rt -> rt : 合并识别结果+关系信息
else 关系发现失败/超时
rt -> rt : 仅返回识别结果
end
rt --> user : identify 结果(含 related_objects)
@enduml
5.3.3 异常场景
- RelationshipCapability 不可用
a. 触发条件:RelationshipCapability 初始化失败或 sciot_import.db 不可用
b. System behavior: Skip relationship discovery, return pure identification results
c. User perception: The returned result has an empty array for related_objects, with source marked as rule_engine_only
- Relationship discovery timeout
a. Trigger condition: identifyRelations() execution exceeds 2 seconds
b. System behavior: Cancel the relationship discovery Promise, return the main query results
c. User perception: The returned result has an empty array for related_objects, with a timeout logged
- Relationship discovery returns a large number of associations
a. Trigger condition: Relationship discovery returns more than 50 associated objects
b. System behavior: Truncate to the first 20 associated objects, append a has_more: true flag
c. User perception: Return a subset of associated objects, with a prompt that further querying is possible
5.4 compare capability relationship layer comparison (P1-1)
5.4.1 Business Rules
- Relationships difference detection: RuleEngine._computeFieldDiffs() SHALL support difference comparison for Relationships nodes.
a. Acceptance criteria: When comparing two objects containing Relationships, the _computeFieldDiffs() SHALL output differences at the relationship layer (added relationships, deleted relationships, modified relationship attributes).
- Relationship difference classification: Relationship differences SHALL be categorized into the following types: relation_added, relation_removed, relation_modified.
a. Acceptance criteria: When a relationship difference is detected, each difference item SHALL include a change_type field with a value of relation_added, relation_removed, or relation_modified.
- Relationship difference details: Each relationship difference item SHALL include relationship_type, related_item_type, related_item_id, and change details.
a. Acceptance criteria: When outputting relationship differences, each difference item SHALL include the fields relationship_type, related_item_type, related_item_id, and the values before and after the change.
- Combined output with field differences: Relationship differences SHALL be output together with field differences in the field_diffs array, distinguished by the change_type prefix.
a. Acceptance criteria: When executeCompare() returns results, the field_diffs array SHALL contain both attribute differences and relationship differences, with the change_type for relationship differences prefixed with relation_.
5.4.2 Interaction Flow
@startuml
actor "用户" as user
participant "CapabilityRuntime" as rt
participant "RuleEngine" as re
user -> rt : compare(context)
rt -> re : executeCompare(context)
re -> re : 查询对象A和对象B
re -> re : _computeFieldDiffs(属性)
re -> re : _computeRelationDiffs(关系)
re -> re : 合并属性差异+关系差异
re --> rt : 对比结果(含关系差异)
rt --> user : 对比结果
@enduml
5.4.3 异常场景
- 对象无 Relationships 数据
a. 触发条件:对比的对象不包含 Relationships 节点
b. System behavior: Skip relationship difference detection and return only attribute differences.
c. User perception: No relationship difference items in the comparison results.
- Relationship type mismatch.
a. Trigger condition: The relationship type sets of the two objects are different.
b. System behavior: Mark the mismatched relationship types as relation_added or relation_removed.
c. User Perception: The comparison results show the addition and deletion of relationship types.
5.5 Optimize Capability Auto-Execution Enhancement (P1-2)
5.5.1 Business Rules
- auto_fix Type Optimization Rule: The system SHALL support optimization rules with action_type: 'auto_fix'. The optimization results shall be automatically submitted to SCSAI.
a. Acceptance Criteria: When the action_type of an optimize rule is auto_fix and the rule matches successfully, the RuleEngine SHALL automatically submit the optimization changes to SCSAI.
- Auto-Execution Pre-Submission Validation: Before automatic submission, the auto_fix optimization rule SHALL validate the impact scope and safety of the changes.
a. Acceptance Criteria: When an auto_fix optimization rule is about to auto-submit, the RuleEngine SHALL verify that the list of changed fields does not include protected fields (e.g., id, created_by, created_on).
- Auto-Execution Result Confirmation: After auto-submission, the auto_fix optimization rule SHALL return the operation confirmation result from SCSAI.
a. Acceptance criteria: When auto_fix optimization rules are automatically submitted to SCSAI successfully, the returned result SHALL include auto_applied: true and the item_id returned by SCSAI.
- Automatic execution failure rollback: When auto_fix optimization rules fail to be automatically submitted, errors SHALL be logged and failure information returned.
a. Acceptance criteria: When auto_fix optimization rules fail to be automatically submitted to SCSAI, the returned result SHALL include auto_applied: false, error information, and the original suggestion content.
- Coexistence of suggest and auto_fix: Within the same scope, suggest and auto_fix optimization rules SHALL be allowed to coexist and be executed sequentially according to priority.
a. Acceptance criteria: When both suggest and auto_fix optimization rules exist for the same ItemType, the RuleEngine SHALL execute them sequentially by priority, with suggest rules returning suggestions and auto_fix rules executing automatically.
5.5.2 Interaction Flow
@startuml
actor "用户" as user
participant "CapabilityRuntime" as rt
participant "RuleEngine" as re
participant "SCSAI" as SCSAI
user -> rt : optimize(context)
rt -> re : executeOptimize(context)
re -> re : 匹配 OPTIMIZE scope 规则
loop 遍历匹配规则
alt action_type = suggest
re --> rt : 优化建议
else action_type = auto_fix
re -> re : 前置校验
re -> SCSAI : applyAML(OptimizeAML)
SCSAI --> re : 操作结果
re --> rt : 自动执行结果
end
end
rt --> user : 优化结果(含建议+自动执行)
@enduml
5.5.3 异常场景
- 受保护字段变更被阻止
a. 触发条件:auto_fix 规则的变更列表包含受保护字段(id、created_by 等)
b. System Behavior: Reject auto-submission, downgrade to suggest return
c. User Perception: Return optimization suggestions instead of auto-execution results, prompt "Involves protected fields, requires manual confirmation"
- SCSAI Submission Conflict
a. Trigger Condition: Object has been modified by other operations when auto_fix submits
b. System Behavior: Record conflict information, return suggest results
c. User Perception: Return optimization suggestions, prompt "Data has changed, please re-evaluate"
5.6 Repair Capability Relationship Repair Enhancement (P1-3)
5.6.1 Business Rules
- Relationship Repair AML Generation: RuleEngine._buildRepairAML() SHALL support including a Relationships node in the repair AML.
a. Acceptance Criteria: When the repair changes of a repair rule include relationship operations (create/modify relationships), the _buildRepairAML() SHALL output a node in the AML.
- Relationship Creation Support: The repair capability SHALL support creating new relationships during repair.
a. Acceptance Criteria: When the action_config of a repair rule contains add_relations instructions, the RuleEngine SHALL add Item nodes for relationship creation in the repair AML.
- Relationship Modification Support: The repair capability SHALL support modifying attributes of existing relationships during repair.
a. Acceptance Criteria: When the action_config of a repair rule contains edit_relations instructions, the RuleEngine SHALL add Item nodes for relationship editing (action="edit") in the repair AML.
- Attribute Repair and Relationship Repair Merging: Attribute repair and relationship repair SHALL be submitted in the same AML to ensure atomicity.
a. Acceptance condition: When repair involves both attribute repair and relationship repair, the generated AML SHALL contain both attribute changes and Relationships nodes within the same node.
5.6.2 Interaction Flow
@startuml
actor "用户" as user
participant "CapabilityRuntime" as rt
participant "RuleEngine" as re
participant "SCSAI" as SCSAI
user -> rt : repair(context)
rt -> re : executeRepair(context)
re -> re : 匹配 REPAIR scope 规则
re -> re : 收集属性修复变更
re -> re : 收集关系修复变更
re -> re : _buildRepairAML(属性+关系)
re -> SCSAI : applyAML(RepairAML)
SCSAI --> re : 操作结果
re --> rt : 修复结果
rt --> user : 修复完成
@enduml
5.6.3 异常场景
- 关系修复引用无效对象
a. 触发条件:关系修复中引用的 related_id 在 SCSAI 中不存在
b. System behavior: SCSAI returns an error, and the overall repair fails.
c. User perception: Returns a repair failure error, prompting "Associated object does not exist."
- Relationship repair and attribute repair partially successful.
a. Trigger condition: Attribute repair succeeds but relationship repair fails.
b. System behavior: SCSAI rolls back the transaction, and attribute repair is also reverted.
c. User perception: Returns repair failure, prompting "Relationship repair failure caused overall rollback."
5.7 create_post Rule Extension (P1-4)
5.7.1 Business Rules
- Post-ECO creation rule: The system SHALL register a CREATE_POST scope built-in rule for the ECO ItemType to handle supplementary operations after the engineering change order is created.
a. Acceptance condition: When an ECO object is successfully created in SCSAI, the RuleEngine SHALL execute the ECO-specific CREATE_POST rule to automatically create ECO Affected Item relationships.
- Post-BOM creation rule: The system SHALL register a CREATE_POST scope built-in rule for the BOM ItemType to handle structure validation and relationship completion after the bill of materials is created.
a. Acceptance condition: When a BOM object is successfully created in SCSAI, the RuleEngine SHALL execute the BOM-specific CREATE_POST rule to validate BOM structure integrity and complete missing relationships.
- Post-Document creation rule: The system SHALL register a CREATE_POST scope built-in rule for the Document ItemType to handle classification and association operations after a document is created.
a. Acceptance condition: When a Document object is successfully created in SCSAI, the RuleEngine SHALL execute the Document-specific CREATE_POST rule to automatically associate it with the corresponding project or product.
- Post-creation rule for Part: The system SHALL register a built-in rule with CREATE_POST scope for the Part ItemType, handling numbering conventions and relationship establishment after part creation.
a. Acceptance criteria: When a Part object is successfully created in SCSAI, the RuleEngine SHALL execute the Part-specific CREATE_POST rule, validating the numbering format and establishing default relationships with the BOM.
- Post-creation rule for Vendor: The system SHALL register a built-in rule with CREATE_POST scope for the Vendor ItemType, handling qualification associations and classification after vendor creation.
a. Acceptance criteria: When a Vendor object is successfully created in SCSAI, the RuleEngine SHALL execute the Vendor-specific CREATE_POST rule, automatically creating vendor classification relationships.
- Execution timing of create_post rules: CREATE_POST rules SHALL execute after the main object is successfully created in SCSAI and before the result is returned.
a. Acceptance criteria: When a create process executes, the CREATE_POST rule SHALL trigger after SCSAI returns the main object ID and complete before the final result is returned to the user.
5.7.2 Interaction Flow
@startuml
actor "用户" as user
participant "CapabilityRuntime" as rt
participant "RuleEngine" as re
participant "SCSAI" as SCSAI
user -> rt : create(context)
rt -> re : executeCreate(context)
re -> SCSAI : applyAML(CreateAML)
SCSAI --> re : 主对象ID
re -> re : 匹配 CREATE_POST 规则
re -> re : 执行 CREATE_POST 规则
re -> SCSAI : applyAML(后置AML)
SCSAI --> re : 后置操作结果
re --> rt : 创建结果(含后置操作)
rt --> user : 创建完成
@enduml
5.7.3 异常场景
- CREATE_POST 规则执行失败
a. 触发条件:CREATE_POST 规则执行抛出异常
b. System behavior: Main object creation is not rolled back; logs are recorded for post-rule failures.
c. User perception: Main object creation is successful; the returned result includes a post_action_warning indicating post-operation failure.
- SCSAI operation failure caused by CREATE_POST rule
a. Trigger condition: The AML submitted by the CREATE_POST rule is rejected by SCSAI.
b. System Behavior: The main object is retained, and SCSAI error information is recorded.
c. User Perception: The main object is created successfully, but the relationship/supplementary operation is incomplete and requires manual handling.
5.8 Identify Built-in Rule Extension (P2-1)
5.8.1 Business Rules
- Part Identification Rule: The system SHALL register a dedicated IDENTIFY scope built-in rule for the Part ItemType.
a. Acceptance Criteria: When a user queries an object of type Part, the RuleEngine SHALL match the dedicated Part identification rule and return an identification result containing the part attribute template and classification information.
- BOM Identification Rule: The system SHALL register a dedicated IDENTIFY scope built-in rule for the BOM ItemType.
a. Acceptance Criteria: When a user queries an object of type BOM, the RuleEngine SHALL match the dedicated BOM identification rule and return an identification result containing the BOM structure and hierarchy information.
- ECO Identification Rule: The system SHALL register a dedicated IDENTIFY scope built-in rule for the ECO ItemType.
a. Acceptance Criteria: When a user queries an object of type ECO, the RuleEngine SHALL match the dedicated ECO identification rule and return an identification result containing the change impact scope and approval status.
- Vendor Identification Rule: The system SHALL register a dedicated IDENTIFY scope built-in rule for the Vendor ItemType.
a. Acceptance Criteria: When a user queries an object of type Vendor, the RuleEngine SHALL match the dedicated Vendor identification rule and return an identification result containing supplier rating and qualification information.
- Document Identification Rule: The system SHALL register a dedicated IDENTIFY scope built-in rule for the Document ItemType.
a. Acceptance Criteria: When a user queries an object of type Document, the RuleEngine SHALL match the dedicated Document identification rule and return an identification result containing document classification and associated object information.
5.8.2 Interaction Flow
@startuml
actor "用户" as user
participant "CapabilityRuntime" as rt
participant "RuleEngine" as re
user -> rt : identify(item_type, query)
rt -> re : executeIdentify(context)
re -> re : 匹配通用 IDENTIFY 规则
re -> re : 匹配 ItemType 专用 IDENTIFY 规则
alt 专用规则命中
re --> rt : 专用识别结果(含类型特有信息)
else 仅通用规则命中
re --> rt : 通用识别结果
end
rt --> user : 识别结果
@enduml
5.8.3 异常场景
- 专用规则条件不匹配
a. 触发条件:ItemType 专用识别规则的条件与查询上下文不匹配
b. System Behavior: Fallback to generic identification rules
c. User Perception: Return generic identification result, with source marked as builtin-identify-001
5.9 RelationshipResolver SCSAI Relationship Query Enhancement (P2-2)
5.9.1 Business Rules
- Existing SCSAI relationship query: RelationshipResolver.discoverRelations() SHALL query existing relationships in SCSAI during relationship discovery.
a. Acceptance Criteria: When discoverRelations() performs relationship discovery, the RelationshipResolver SHALL first query SCSAI to obtain the existing relationship list for the object, avoiding duplicate creation.
- Deduplication logic: discoverRelations() SHALL deduplicate candidate relationships identified by RelationshipCapability against existing relationships in SCSAI.
a. Acceptance Criteria: When a candidate relationship duplicates an existing relationship in SCSAI, discoverRelations() SHALL mark it as already_exists: true in the returned results and exclude it from the pending creation list.
- Existing relationship information attachment: discoverRelations() return results SHALL include information about existing relationships in SCSAI.
a. Acceptance Criteria: When discoverRelations() returns results, the results SHALL include an existing_relations array listing relationships already present in SCSAI.
- SCSAI query failure tolerance: Failure of SCSAI relationship query SHALL NOT affect local relationship discovery by RelationshipCapability.
a. Acceptance Condition: When the SCSAI relationship query times out or fails, the discoverRelations() SHALL continue to execute local relationship discovery, and existing_relations shall be an empty array.
5.9.2 Interaction Flow
@startuml
actor "CapabilityRuntime" as rt
participant "RelationshipResolver" as rr
participant "SCSAI" as SCSAI
participant "RelationshipCapability" as rc
rt -> rr : discoverRelations(item_type, items)
rr -> SCSAI : 查询已有关系
SCSAI --> rr : 已有关系列表
rr -> rc : identifyRelations(item_type, item_data)
rc --> rr : 候选关系列表
rr -> rr : 去重:候选 vs 已有
rr --> rt : 发现结果(含 existing_relations + new_relations)
@enduml
5.9.3 异常场景
- SCSAI 查询超时
a. 触发条件:SCSAI 关系查询超过 3 秒未响应
b. System Behavior: Cancel the SCSAI query and return only the local relationship discovery results.
c. User Perception: existing_relations is empty, and candidates may contain duplicate relationships.
- SCSAI Returns Malformed Data
a. Trigger Condition: The relationship data returned by SCSAI cannot be parsed.
b. System Behavior: Skip the SCSAI relationship list and use only the local discovery results.
c. User Perception: existing_relations is empty, and a parsing error is logged.
6. Data Constraints
6.1 Rule Object (sciot_rules_v2)
- id: Unique identifier, formatted as builtin-{scope}-{sequence number}, e.g., builtin-generate-001
- scope: Must be one of the RULE_SCOPES enumeration values (IDENTIFY/CREATE/CREATE_PRE/CREATE_POST/REPAIR/OPTIMIZE/COMPARE/GENERATE/TRANSFORM/INSPECT)
- item_type_name: Must be filled for ItemType-specific rules; null for generic rules.
- action_type: Must be one of suggest, auto_fix, block, warn.
- priority: P0 > P1 > P2; rules with the same priority are sorted by id.
- is_builtin: 1 for built-in rules, 0 for database rules.
- is_active: Rule activation status, defaults to 1.
6.2 Relationship Discovery Result (discoverRelations return value)
- existing_relations: Array of existing SCSAI relationships, each element containing relationship_type, related_id, related_type.
- new_relations: Array of relationships to be created, each element contains relationship_type, related_item_type, related_item_id, action
- already_exists: Boolean flag, true when a candidate relationship duplicates an existing one
6.3 identify Return Result (including relationship information)
- related_objects: Array of related objects, each element contains relationship_type, related_item, direction
- has_more: Boolean flag, true when related objects exceed 20
- source: Result source marker, value is one of rule_engine, llm_router, rule_engine_only
6.4 AML Relationships Node
- Relationships: XML node containing zero to multiple child nodes
- Relationship Item: Must contain a type attribute (relationship type name) and an action attribute (add/edit/delete)
- related_id: The object ID referenced by the relationship, must be in the 22-digit SCSAI standard format
- properties: Relationship properties, format consistent with main object properties
6.5 compare Difference Result (including relationship differences)
- field_diffs: Unified difference array, containing both attribute differences and relationship differences
- change_type: Attribute differences are added/removed/modified; relationship differences are relation_added/relation_removed/relation_modified
- relationship_type: Relationship difference items must contain this field, identifying the relationship type name
BossAgents