Left Arm Right Arm · Governance Native Architecture Refactoring ·…

Left Arm Right Arm · Governance Native Architecture Refactoring · Implementation Summary v1

1. Project Background

1.1 Problem Status

Before refactoring, governance logic was separated from business data: the application layer (server.js) handled asset governance calculations, while SCSAI only served as business data

For data storage, the local SQLite data_assets table serves as the master asset library. Business additions, deletions, and modifications do not automatically generate governance records; the front-end BOM

detail page cannot directly view asset attributes and governance history.

1.2 Target Architecture

Core principle: All governance logic is pushed down to the SCSAI server-side Method; the application layer is only responsible for displaying results.

┌──────────────┐     ┌──────────────────────────────────────┐
│  应用层      │     │  SCSAI 服务端(运行时环境)             │
│  (仅展示)     │ ←→  │  Part/BOM + 资产属性 + GovernanceLog │
│              │     │  OnAfterUpdate Method (自动治理)       │
└──────────────┘     └──────────────────────────────────────┘
                              ↓
                    ┌──────────────────────────┐
                    │  data_assets(缓存视图)   │
                    │  加速查询,不存真相         │
                    └──────────────────────────┘

2. 实施范围

2.1 SCSAI 数据模型(任务 1-3)

| 对象 | 新增属性 | 关系类型 |

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

| Part | asset_class(general), valuation, quality_score, governance_status(pending), last_inspection | Part Governance Log |

| BOM | Same as above, asset_class defaults to bom | BOM Governance Log |

| Process | Same as above, asset_class defaults to process | Process Governance Log |

2.2 GovernanceLog ItemType (13 attributes)

action_type, operator_type, operator_id, operator_name, target_item_id,

target_item_type, before_data, after_data, diff_summary, impact_quality,

impact_value, timestamp, id(auto)

2.3 SCSAI Server Method (Tasks 4-5)

MethodTrigger EventFunction
OnGovernanceTriggerPart/BOM/Process → OnAfterUpdateComplete governance process: Calculate quality score → Update valuation → Write log → Establish relationships
BatchGovernanceManual call (Evaluate)Batch mode: Update asset attributes, write only 1 summary log

2.4 Application Layer API (Task 6)

EndpointMethodFunction
/api/dashboard/asset-overviewPOSTQuery total count/total valuation/average quality score/governance status of Part+BOM assets
/api/dashboard/today-governancePOSTQuery today's GovernanceLog statistics and the latest 10 entries

2.5 Frontend Modifications (Tasks 7-10)

ComponentChanges
BomDetailModal.vueIntegrated 5 asset attributes into the Basic Info tab; Integrated governance logs (sorted reverse chronologically) into the Change History tab; Deleted standalone Asset/Governance/Related Assets/Capability Operation tabs and 300+ lines of redundant code
Dashboard.vueAdded 4 cards for "Enterprise Data Asset Overview" + "Today's Governance Activity" log list
AiWorkbench.vueAdded governance impact section to Part/BOM repair operation results
DigitalStaff.vueTask success log automatically appends asset contribution (quality/value change)

3. File List

New files (6)

server/scripts/phase3-governance-setup.js        — SCSAI 自动配置脚本
server/scripts/phase3-verify.js                  — 验证脚本(对应第9章清单)
server/scripts/methods/OnGovernanceTrigger.cs    — 触发式治理Method(C#)
server/scripts/methods/BatchGovernance.cs         — 批量治理Method(C#)

修改文件(4个)

server.js                                        — +2 dashboard API 端点
src/components/BomDetailModal.vue                — 资产融合 + 治理融合 + 代码清理
src/views/Dashboard.vue                          — +资产总览 + 治理动态
src/views/AiWorkbench.vue                        — +治理结果回复
src/views/DigitalStaff.vue                       — +资产贡献日志

4. 部署步骤

步骤 A:SCSAI 数据模型(自动)

node server/scripts/phase3-governance-setup.js

自动执行:

  • Create 5 asset attributes for Part/BOM/Process
  • Create GovernanceLog ItemType with 13 attributes
  • Create 3 relationship types

Step B: SCSAI Method (Manual)

  1. Log in to SCSAI Admin Console → Administration → Methods
  2. Create a new Method, named OnGovernanceTrigger, type Server Method (C#)
  3. Paste the content from server/scripts/methods/OnGovernanceTrigger.cs
  4. Repeat the above to create BatchGovernance
  5. Navigate to Part → Events → OnAfterUpdate → Bind OnGovernanceTrigger
  6. Repeat binding for BOM and Process

Step C: Application Layer

# 重启服务器以加载新 API 端点
npm restart
# 或
node server.js

步骤 D:验证

node server/scripts/phase3-verify.js

5. 验证清单

| # | 验证项 | 验证方式 |

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

| 1 | Part contains 5 asset attributes | SCSAI Admin Console / verify script |

| 2 | BOM/Process contain asset attributes, default values correct | Same as above |

| 3 | GovernanceLog exists, containing 13 attributes | Same as above |

| 4 | 3 relationship types created | Same as above |

| 5 | OnGovernanceTrigger mounted to OnAfterUpdate | Manually check the Events tab |

| 6 | Edit Part's description → quality_score updates automatically | End-to-end test |

| 7 | Governance logs automatically generated and linked | End-to-end testing |

| 8 | BatchGovernance mode writes only 1 log entry | Validate with 10 IDs |

| 9 | BOM detail page displays asset attributes | Frontend verification |

| 10 | Change record Tab shows governance logs | Frontend verification |

| 11 | Dashboard displays asset overview + governance activity | Frontend verification |

| 12 | Dialog returns governance change comparison | Frontend verification |

| 13 | Digital employee logs display asset contributions | Frontend verification |

| 14 | No independent asset/governance Tab | Code review |

| 15 | No independent /api/governance/* routes | Code review |

| 16 | No new write logic in data_assets | Code review |


6. Implementation Red Lines (Adhered to)

  • ❌ Did not add new governance-related tables in local SQLite
  • ❌ Did not add new governance utility functions at application layer
  • ❌ Did not create independent governance API routes
  • ❌ Did not add independent asset/governance Tab
  • ❌ Did not modify data_assets table structure or write logic
  • ❌ No frontend actively calls governance interfaces

7. Governance Logic Explanation

Governance Process (Automatically Triggered)

SCSAI 编辑 Part/BOM/Process
       │
       ▼
OnAfterUpdate 触发 OnGovernanceTrigger Method
       │
       ├─ 读取 skip_governance flag(跳过控制)
       ├─ 检查 batch_mode(批量模式仅更新属性)
       └─ 完整治理流程:
           1. ValidateCompleteness — 检查 name/number/classification/description
           2. CalculateQualityScore — 完成度 × 0.7(满分100)
           3. CalculateValuation — baseValue(¥10,000) × qualityFactor
           4. 更新 quality_score / valuation / governance_status / last_inspection
           5. Create GovernanceLog 记录
           6. 建立关联关系(Part Governance Log 等)

治理状态定义

| 状态 | 条件 | 含义 |

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

| governed | quality_score ≥ 90 | Governed |

| pending | 60 ≤ quality_score

| exception | quality_score


8. Appendix: Core Code Examples

Asset Attribute Query

<!-- 查询 Part 资产属性 -->
<Item type="Part" action="get" id="..." select="id,asset_class,valuation,quality_score,governance_status,last_inspection"></Item>

Governance Log Query

<!-- 查询某 Part 的所有治理日志 -->
<Item type="Part" action="get" id="...">
  <Relationships>
    <Item type="Part Governance Log" action="get"
      select="action_type,operator_name,timestamp,diff_summary,impact_quality,impact_value"
      orderby="timestamp desc">
    </Item>
  </Relationships>
</Item>

Batch Governance Invocation

<Item type="Method" action="Evaluate">
  <name>BatchGovernance</name>
  <itemType>Part</itemType>
  <itemIds>ID1,ID2,ID3</itemIds>
</Item>
← 返回案例列表

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 →
🤖
🎁