SCSAI Digital Employee Platform — Rule Engine SOUL

SCSAI Digital Employee Platform — Rule Engine SOUL

Version: 3.0

Update Date: 2026-05-09

Core Concept: Natural Language → Keyword Recognition → Rule Matching → Tool Invocation → Result Return

Ultimate Goal: A Self-Operating, Self-Evolving Industrial Digital Employee System


I. System Soul (SOUL)

1.1 What is This

SCSAI is a rule-driven digital employee platform. It is not a simple chatbot, but a closed-loop business operating system:

``

Boss/Employee issues a command (natural language)

↓

Keyword Recognition Engine (L1: Pure rules, no LLM required)

↓

Rule Template Matching (ai-agent-rules.json)

↓

┌─ need_llm=false → Directly invoke API to execute

└─ need_llm=true → LLM-assisted understanding + Execute after confirmation

↓

Execution result returned (Frontend/Feishu/Automatic operation)

↓

System self-learning and self-optimization

`

1.2 Three-Level Intelligence Strategy

| Level | Trigger Condition | Processing Method | Latency | Cost |

|------|----------|----------|------|------|

| L1 Rule Direct | Keywords hit rules with need_llm=false | Directly call tool API |

| L2 Rule+LLM | Keywords hit rules with need_llm=true | LLM extracts parameters → User confirmation → Execution | 1-3s | Low |

| L3 Pure LLM | Keywords hit no rules | LLM understands intent → Reasons over tools → Confirmation → Execution | 3-10s | Medium |

Core principle: Never call LLM for tasks solvable by rules; never escalate to L2/L3 if L1 can handle.


II. Rule Template System (RULES)

2.1 Rule Template Structure

Each rule is a "soul fragment," defining how the system understands a category of instructions:

`json

{

"id": "Unique rule identifier",

"name": "Rule name (Chinese)",

"keywords": ["Keyword1", "Keyword2"],

"need_llm": false,

"action": {

"tool": "Tool name",

"params": { "parameter name": "parameter value template" },

"required_fields": ["Required fields"],

"SCSAI_type": "SCSAI object class name (optional)",

"SCSAI_select": "SCSAI query fields (optional)"

},

"examples": ["Example command 1", "Example command 2"]

}

`

2.2 Rule Matching Algorithm

`

Input: User message "Create supplier Huawei, phone 12345678"

↓

  1. Convert to lowercase: "create supplier huawei, phone 12345678"

↓

  1. Iterate through all rules, calculate the keyword hit count for each rule:
  • create_vendor: "create"✓ "supplier"✓ "vendor"✓ → score 3
  • create_project: "create"✓ → score 1
  • query_vendors: "supplier"✓ "vendor"✓ → score 2

↓

  1. Highest-scoring rule: create_vendor (score 3)

↓

  1. need_llm=true → Attempt to extract parameters from the message:
  • name: "Huawei" (extracted from message)
  • phone: "12345678" (extracted from message)

↓

  1. Return confirmation: "I understand you want to create a supplier: Huawei, confirm execution?"

↓

  1. User confirms → Call create_vendor tool → Execute

`

2.3 Complete Rule List (47 items)

#### ? Query Rules (L1 Direct Pass, No LLM Required)

| ID | Rule Name | Keywords | Tool | Description |

|----|----------|--------|------|------|

| query_item_types | Query Object Class List | object class/list/ItemType/type | search_item_types | View all object class definitions in the system |

| query_inventory | Query Inventory | inventory/query/material/stock | list_data(inventory_items) | View inventory material list |

| query_projects | Query Projects | project/list/progress/project | list_data(projects) | View project list and progress |

| query_quality | Query quality data | Quality/Inspection/NCR/Pass Rate | list_data(inspections) | View quality inspection records |

| query_vendors | Query vendors | Supplier/Vendor/Manufacturer/List | list_data(vendors) | View vendor list |

| query_documents | Query documents | Document/Drawing/Document/File | list_data(documents) | View document list |

| query_cad | Query CAD drawings | CAD/Drawing/cad | list_data(documents) | View CAD drawings |

| query_customers | Query customers | Customer/Customer/Customer List | list_data(customers) | View customer list |

| query_work_orders | Query work orders | Work Order/Production/Work_Order | list_data(orders) | View production work orders |

| dashboard | Data overview | Overview/Statistics/Dashboard/Data | dashboard_summary | Dashboard data summary |

| compare_item_types | Comparison Object Types | compare/comparison/difference/diff | compare_item_types | Local vs. SCSAI Difference Comparison |

| system_health | System Health Check | health/status/system/check | system_health | Database/SCSAI/LLM Status |

| export_data | Export Data | export/download/export/excel | export_data | Export Module Data |

#### ? System Operation and Maintenance Rules (L1 Direct)

| ID | Rule Name | Keywords | Tool | Description |

|----|----------|--------|------|------|

| optimize_item_types | Batch Optimize Object Types | optimize/object type/attribute/completion | optimize_item_types | Automatically Complete Missing Attributes |

| import_item_types | Import Object Classes | Import/Sync/Object Classes/AML | import_item_types | Import from AML file |

| repair_item_type | Repair Object Classes | Repair/Object Classes/Integrity | repair_item_type | Repair object class definitions |

#### ✏️ Create Class Rules (L2 requires LLM assistance for understanding)

| ID | Rule Name | Keywords | Tool | SCSAI Type | Required Fields |

|----|----------|--------|------|----------|----------|

| create_vendor | Create Vendor | Create/Add/Vendor/Manufacturer | create_vendor | Vendor | name |

| create_project | Create Project | Create/Add/Project | create_project | Project | name |

| create_ecr | Create Change Request | Create/Add/Change Request/ECR/Change | create_SCSAI_item | ECR | name |

| create_ncr | Create Nonconformance Report | Create/Add/Nonconformance/NCR/Quality | create_ncr | NCR | title |

| create_purchase_order | Create Purchase Order | Create/Purchase/PO | create_SCSAI_item | pop_purchase_order | name |

| create_sales_order | Create Sales Order | Create/Sales/SO/Order | create_SCSAI_item | sop_sale_order | name |

| create_work_order | Create Work Order | Create/Work Order/Production Order | create_SCSAI_item | Work_Order | name |

| create_document | Create Document | Create/Document/Upload | create_SCSAI_item | Document | name |

#### ? Inventory Operation Rules (L2 requires LLM assistance for understanding)

| ID | Rule Name | Keywords | Tool | SCSAI Type | Required Fields |

|----|----------|--------|------|----------|----------|

| inventory_outbound | Inventory Outbound | Outbound/Picking/Shipment/Deduct Inventory | inventory_transaction | stk_issue | part_number, quantity |

| inventory_inbound | Inventory Inbound | Inbound/Receipt/Inbound Order | inventory_transaction | stk_issue | part_number, quantity |

#### ?️ Tagging Rules (L2 requires LLM assistance for understanding)

| ID | Rule Name | Keywords | Tool | Required Fields |

|----|----------|--------|------|----------|

| toggle_core | Set as Core Object | Core/Business Object/Tag | toggle_core_business | item_type_name |

#### ? Analysis Rules (L2 requires LLM assistance for understanding)

| ID | Rule Name | Keywords | Tool | Required Fields |

|----|----------|--------|------|----------|

| analyze_trends | Trend Analysis | Trend/Analysis/Statistics/Report | analyze_trends | module |


III. Tool Registry (TOOLS)

3.1 Tool Definition

Each tool serves as the "hands and feet" of a rule template, defining the specific execution logic:

| Tool Name | Description | Required Parameters | Data Source |

|--------|------|----------|--------|

| search_item_types | Search Object Classes | None | SQLite |

| get_item_type_detail | Get Object Class Details | name | SQLite |

| list_data | Query Business Data List | module | SQLite |

| create_vendor | Create Vendor | name | SQLite + SCSAI |

| create_project | Create Project | name | SQLite |

| create_ncr | Create NCR | title | SQLite |

| create_quality_inspection | Create Quality Inspection | title, inspection_type | SQLite |

| create_inventory_item | Create Inventory Item | part_number, part_name | SQLite |

| inventory_transaction | Inventory Transaction | part_number, transaction_type, quantity | SQLite |

| create_SCSAI_item | General SCSAI Object Creation | item_type, name | SQLite + SCSAI |

| optimize_item_types | Batch Optimize Object Classes | None | SQLite |

| repair_item_type | Repair Object Class | name | SQLite |

| toggle_core_business | Set Core Object Flag | item_type_name, is_core | SQLite |

| import_item_types | Import object classes from AML | source | AML file + SQLite |

| compare_item_types | Compare object class differences | None | SQLite + SCSAI |

| dashboard_summary | Dashboard summary | None | SQLite |

| system_health | System health check | None | SQLite + SCSAI + LLM |

| analyze_trends | Trend analysis | module | SQLite |

| export_data | Data export | module | SQLite |

3.2 Tool Execution Flow

`

executeTool(toolName, params)

↓

  1. Find tool in TOOLS array

↓

  1. Validate required parameters (required)

↓

  1. Call tool.handler(params)

↓

  1. Return { type: 'result', success: true, data: ... }

or { type: 'error', message: '...' }

`


IV. SCSAI Object Class Mapping

4.1 PLM Core Object Classes

Object ClassSCSAI Type NameAML File PathPurpose
PartPartPLM/Import/ItemType/Part.xmlBOM Management
DocumentDocumentPLM/Import/ItemType/Document.xmlDocument Management
CAD DrawingCADPLM/Import/ItemType/CAD.xmlDrawing Management
VendorVendorPLM/Import/ItemType/Vendor.xmlVendor Management
CustomerCustomerPLM/Import/ItemType/Customer.xmlCustomer Management
Change RequestECRPLM/Import/ItemType/ECR.xmlEngineering Change

4.2 SCIOT Extended Object Classes

Object ClassSCSAI Type NameAML File PathPurpose
ProjectProjectSCIOT/SCIOT/Project/Import/ItemType/Project.xmlProject Management
Project TaskProject TaskSCIOT/SCIOT/Project/Import/ItemType/Project Task.xmlTask Management
Nonconformance ReportNCRSCIOT/SCIOT/QS/Import/ItemType/NCR.xmlQuality Management
Corrective & Preventive ActionQAPSCIOT/SCIOT/QS/Import/ItemType/QAP.xmlQuality Management
Inventory Setupstk_stock_setupSCIOT/SCIOT/WEFIC_ACCOUNTING/Import/ItemType/stk_stock_setup.xmlInventory Management
Issue Slipstk_issueSCIOT/SCIOT/WEFIC_ACCOUNTING/Import/ItemType/stk_issue.xmlInventory Management
Stock Transferstk_stock_transferSCIOT/SCIOT/WEFIC_ACCOUNTING/Import/ItemType/stk_stock_transfer.xmlInventory Management
Purchase Orderpop_purchase_orderSCIOT/SCIOT/WEFIC_ACCOUNTING/Import/ItemType/pop_purchase_order.xmlProcurement Management
Sales Ordersop_sale_orderSCIOT/SCIOT/WEFIC_ACCOUNTING/Import/ItemType/sop_sale_order.xmlSales Management
Work OrderWork_OrderSCIOT/SCIOT/WEFIC_ACCOUNTING/Import/ItemType/Work_Order.xmlProduction Management

4.3 SCIOT Object Relationship Types

Real relationship types discovered from ItemType.xml (non-SCSAI standard names):

| Relationship Type | Query Method | Description |

|----------|----------|------|

| Property | | Direct relationship |

| Method | | Direct relationship |

| View | | Direct relationship |

| Allowed Permission | | Direct relationship |

| Server Event | | Direct relationship |

| Item Action | | Direct relationship |

| RelationshipType | | Queried via source_id |


V. Closed-Loop Execution Example

Example 1: L1 Direct Pass — "View Inventory"

`

User: "View Inventory"

↓

Keyword match: "Inventory"✓ "Query"✓ → query_inventory (score 2, need_llm=false)

↓

Direct execution: list_data({ module: "inventory_items" })

↓

SQL: SELECT * FROM inventory_items ORDER BY created_at DESC LIMIT 50

↓

Return: { type: 'result', data: { total: 156, items: [...] } }

↓

Frontend displays inventory list

`

Example 2: L2 Rule + LLM — "Create vendor Huawei, phone 12345678"

`

User: "Create vendor Huawei, phone 12345678"

↓

Keyword matching: "create"✓ "vendor"✓ "vendor"✓ → create_vendor (score 3, need_llm=true)

↓

Parameter extraction: name="Huawei", phone="12345678"

↓

Return confirmation: { type: 'confirm', message: "I understand you want to create vendor: Huawei\n\nConfirm execution?" }

↓

User clicks "Confirm"

↓

Execute: create_vendor({ name: "Huawei", phone: "12345678" })

↓

  1. SQLite: INSERT INTO vendors (id, name, phone, ...) VALUES (...)
  2. SCSAI: POST /server/odata/Part → Create Vendor object

↓

Return: { type: 'result', message: "Vendor created successfully (synced to SCSAI)" }

`

Example 3: Feishu Remote Command — "Inventory Alert"

`

Boss in Feishu group @Digital Assistant: "Inventory Alert"

↓

Feishu event push → POST /api/feishu/webhook

↓

handleMessageEvent → aiAgent.processMessage("Inventory Alert")

↓

Keyword matching: "inventory"✓ "alert"✗ → query_inventory (score 1, need_llm=false)

↓

Execute: list_data({ module: "inventory_items" })

↓

Feishu reply: "Current inventory alert items total 12:\n1. R001 Resistor - Current 0 Safety 100\n2. ..."

`


VI. AI Inspection System (Self-Evolution Core)

6.1 Inspection Architecture

The AI Inspection System is the core engine for platform self-evolution. It continuously detects data quality issues in SCSAI object classes, automatically fixes and validates them:

`

Inspection (1,197 object classes) → Problem identification (5 rule categories) → One-click fix (SSE real-time progress) → Automatic re-inspection verification

`

6.2 Inspection Rules (5 rules, all auto-fixable)

Rule IDNameCategorySeverityFix Method
rule-001Must have Chinese labelBasic SpecificationerrorBuilt-in translation mapping table (100+ entries) + DeepSeek fallback
rule-002Must have a number fieldData IntegrityerrorAutomatically add item_number attribute
rule-003Must have a name fieldData IntegrityerrorAutomatically add name attribute
rule-004Must have a status fieldLifecyclewarningAutomatically add state attribute
rule-005Must have audit fieldsAudit TrailwarningAutomatically add created_by_id attribute

6.3 Technical Points for Fixing

  • Serial execution + 200ms delay: Avoid SCSAI database deadlock
  • Retry mechanism: Automatic deadlock retry, up to 2 times
  • SSE real-time push: Push to frontend immediately after each fix item completes
  • Data separation: SSE only pushes summary; full issues fetched via JSON API (to avoid frontend lag from large data)
  • Authentication passthrough: Frontend passes current logged-in user's authentication to server, fixes executed using that user's permissions

6.4 API Interfaces

RouteMethodFunction
/api/ai-inspector/inspect-streamPOSTSSE streaming inspection
/api/ai-inspector/fix-streamPOSTSSE streaming fix
/api/ai-inspector/last-resultPOSTGet latest full inspection result
/api/ai-inspector/rulesGETGet rule list

Seven. Digital Employee Team

7.1 Current On-Duty Employees (4 persons)

Employee IDNamePositionDepartmentScheduling CycleCore Capabilities
DS-ECR-001XiaoZhi-ECR ReviewerJunior Change Management ReviewerQuality DepartmentEvery 15 minutesLLM intelligent initial ECR review, auto-approval if confidence >0.8
DS-VEN-001XiaoZhi-Supplier StewardSupplier Quality Management SpecialistProcurement DepartmentEvery 30 minutesSupplier quality score monitoring, triggers diagnosis if below 75
DS-COST-001XiaoZhi-Cost OptimizerCost Analysis EngineerFinance DepartmentDaily at 2 AMBOM cost scanning, alternative material recommendation, ROI analysis
DS-DATA-001XiaoZhi-Data ClerkData Synchronization EngineerIT DepartmentHourlySCSAI data sync to local cache (6 object types)

7.2 LLM Brain Capabilities

CapabilityRole SettingOutput
ECR Intelligent ReviewCCB Expertdecision / confidence / riskLevel
Supplier Intelligent DiagnosisQuality ExperthealthScore / risk / improvementPlan
BOM Cost OptimizationCost ExpertalternativeMaterialRecommendation / ROI analysis
5Why Root Cause Analysis6 Sigma Black Belt5-level Why chain / correctivePreventiveActions

Eight. Self-Operation & Self-Evolution Roadmap

Phase One: Rule-Driven (✅ Completed)

  • ✅ 47 rule templates covering core business
  • ✅ 42 utility functions implementing business operations
  • ✅ Three-level intelligent strategy (L1/L2/L3)
  • ✅ Feishu bot remote commands
  • ✅ Keyword matching + LLM fallback
  • ✅ AI inspection system (5 rules, SSE real-time fixes)
  • ✅ 4 digital employees working autonomously
  • ✅ SCSAI SOAP API integration
  • ✅ Dual-write data architecture (SCSAI + SQLite)

Phase 2: Self-Learning (? In Progress)

  • ? Operation Log Analysis → Automatic Discovery of High-Frequency Commands → Automatic Generation of New Rules
  • ? User Feedback Collection → Optimization of Rule Keyword Weights
  • ? Rule Conflict Detection → Automatic Priority Adjustment
  • ? AML Change Monitoring → Automatic Synchronization of Object Class Definitions
  • ? Inspection Rule Expansion (Relationship Types/Lifecycle/Permissions/Naming Conventions)

Phase 3: Self-Operation and Maintenance (? Planned)

  • ✅ Scheduled Health Check → Data Scribe Already Implemented
  • ? Inventory Alert → Automatic Triggering of Procurement Suggestions
  • ? Quality Trend Analysis → Automatic Initiation of Corrective Actions
  • ? System Anomaly Detection → Automatic Diagnosis and Repair
  • ? Object Class Integrity Automatic Inspection → Automatic Repair (AI Inspection System Basic Version Already Implemented)

Phase 4: Self-Evolution (Long-term)

  • ? Business Process Mining → Automatically Discover Standard Processes
  • ? Rule Auto-generation → Learn New Rules from Historical Operations
  • ? Cross-Module Linkage → Automatically Trigger Related Operations
  • ? Predictive Maintenance → Proactively Identify Potential Issues

IX. Core Business Module Mapping

9.1 Business Module → SCSAI Object Class → Rule/Tool Mapping

Business ModuleSCSAI Object ClassImplemented RulesImplemented ToolsDigital Employee
BOM ManagementPart, CADquery_item_typesoptimize_item_typesCost Optimization Engineer
Change ManagementECR, ECOcreate_ecrcreate_SCSAI_itemECR Reviewer
Project ManagementProject, Project Taskcreate_projectcreate_project-
Quality ManagementNCR, QAPcreate_ncr, analyze_root_causecreate_ncr, analyze_root_cause, generate_quality_report-
Process Management-optimize_process_paramsoptimize_process_params, run_mold_flow_analysis-
Vendor ManagementVendor, Manufacturercreate_vendor, query_vendorscreate_vendorVendor Management
Customer ManagementCustomerquery_customerscreate_SCSAI_item-
Inventory Managementstk_stock_setup, stk_issueinventory_inbound/outboundinventory_transaction, create_inventory_item-
Procurement Managementpop_purchase_ordercreate_purchase_ordercreate_SCSAI_item-
Sales Managementsop_sale_ordercreate_sales_ordercreate_SCSAI_item-
Production ManagementWork_Ordercreate_work_ordercreate_SCSAI_item, get_production_status-
Equipment Management-predict_health, predict_tool_wearpredict_device_health, predict_tool_wear-
Green Manufacturing-carbon_managementcalculate_carbon_footprint-

9.2 Business Modules to be Improved

Business ModuleMissing ContentPriority
Project ManagementLacks project progress tracking, Gantt chart, milestone management toolsHigh
Quality ManagementLack of real-time SPC monitoring and automatic CPK calculation toolsHigh
Process ManagementProcess parameter optimization is simulated and requires integration with real modelsMedium
Equipment ManagementEquipment health prediction is simulated and requires IoT data integrationMedium
Customer ManagementLack of customer segmentation, credit evaluation, and order analysis toolsMedium

10. Known Limitations and Improvement Directions

10.1 Current Limitations

  1. Simulated Implementation: Approximately 13 advanced tools (visual inspection, equipment prediction, process optimization, etc.) still use simulated data.
  2. Insufficient Inspection Rules: Only 5 basic rules, lacking checks for relationship types, lifecycle, permissions, etc.
  3. Data Synchronization Limitations: Only 6 SCSAI object types are synchronized, missing BOM/Project/Customer, etc.
  4. Insufficient Digital Employee Coverage: Only 4 digital employees cover 47 rules.
  5. Lack of Testing Framework: No unit tests or integration tests.

10.2 Near-term Improvement Directions

  1. Expand Inspection Rules: Add rules for relationship type integrity, attribute label localization, naming conventions, etc.
  2. Add New Digital Employees: Quality Inspector, Inventory Manager, Production Scheduler.
  3. Business Loop Closure: Inspection Discovery → Automatic Repair → Verification → Continuous Monitoring.
  4. Large Model Integration: Combine inspection repair with LLM rule templates for intelligent repair decision-making.

11. How to Extend

7.1 Adding New Rules

Edit server/ai-agent-rules.json and add to the rules array:

`json

{

"id": "your_rule_id",

"name": "Rule Name",

"keywords": ["keyword1", "keyword2"],

"need_llm": false,

"action": {

"tool": "corresponding_tool_name",

"params": {}

},

"examples": ["Example Instruction"]

}

`

7.2 Adding New Tools

Edit server/ai-agent.js and add to the TOOLS array:

`javascript

{

name: 'your_tool_name',

description: 'Tool description',

parameters: {

type: 'object',

properties: {

param1: { type: 'string', description: 'Parameter description' }

},

required: ['param1']

},

handler: async (params) => {

// Implement your business logic here

return { result: 'success' };

}

}

`

7.3 Add a New SCSAI Object Class

  1. Create an AML definition file for the ItemType in SCSAI/SCIOT
  2. Add corresponding creation/query rules in ai-agent-rules.json
  3. Add corresponding tools in ai-agent.js if special logic is required
  4. The system will automatically synchronize the new object class via import_item_types

12. File Index

FilePurpose
server/ai-agent-rules.jsonRule template definitions (31 rules)
server/ai-agent.jsAI agent core (19 tools + intent recognition + execution engine)
server/digital-staff/llm-brain.jsLLM brain (ECR review/supplier analysis/BOM optimization/5Why root cause)
server/feishu-bot.jsFeishu bot integration (event reception + message reply + proactive push)
server/routes/aml.jsAML routes (optimization/fix/comparison/core marking)
server/database1.jsDatabase management (SQLite + auto migration)
server/utils/SCSAI-connection.jsSCSAI connection utility (SOAP API wrapper)
frontend/app.jsFrontend application (Vue 3 + SCSAI integration + AI assistant UI)
index-vue.htmlMain page (sidebar + 12 tabs + AI assistant)
frontend/styles.cssStyles (light/dark theme + responsive layout)
← 返回案例列表

Try 左帮右臂 Industrial Agent — your digital workforce

Available as a WeChat mini program, web app (ylxt.chat) and desktop client. Start from whichever fits your workflow.

🌐 Web App 💻 Desktop Download 📞 Call 189-8606-6876
WeChat mini program QR
Scan for the WeChat mini program
Share:
🤖 Try Now →
🤖
🎁