规则、模板、提示词分层存储与同步 — 完整实施方案(v2)

规则、模板、提示词分层存储与同步 — 完整实施方案(v2)


一、现状全景

1.1 数据链路全貌

AML 源文件 (SCIOT/ 目录, 636 个 *.xml)
   │ 三条流水线 (import-aml-v2.js → extract-extended-aml.js → generate-operation-rules.js)
   ▼
sciot_import.db (38MB)        ← 本地结构化数据库,规则/模板/提示词唯一真实源头
   │
   ▼  (CRUD/预生成/查询)
BossAgents 后端 (server.js) + 前端 (Vue app.js)

#### 数据库内容概要

| 表 | 行数 | 内容 |

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

| sciot_item_types | 928 | 对象类定义 |

| sciot_properties | 40,854 | 属性定义 |

| sciot_relationships | 587 | 关系类型 |

| sciot_rules_v2 | 2,371 | 规则引擎 — scope分布:validate(1080)/create_pre(678)/identify(506)/instance(26)/repair(25)/model(20)/compare(11)/optimize(10)/create(5)/update_pre(5)/inspect(4)/create_post(1) |

| sciot_templates | 1,205 | 模板 — 按 template_type 分类 |

| prompt_templates | 2,817 | 提示词 — operation_type: add(935)/get(928)/edit(928)/generate(26) |

| sciot_business_prompts | 46 | 业务系统提示词 |

#### 消费端

  • 前端创建面板:读 sciot_properties + sciot_rules + sciot_templates → 前端自验证 → 前端自组装 → 调 SCSAI AML API 写入
  • 前端规则引擎面板:5 个功能模块(规则管理/模板库/对象提示词/业务提示词/AML组装器),直接 CRUD sciot_rules_v2 / prompt_templates / sciot_templates
  • AI Workbench / LLM 模块:读 prompt_templates 生成结构化提示词

1.2 SCSAI 服务端现状(实调查)

SCSAI 服务: http://114.113.153.234/scplm
用户: root
密码: gyc123456;           ← 注意末尾分号
数据库: SCPLM

#### ✅ 已存在的相关 ItemType

通过 AML API 对 SCSAI 服务端进行完整扫描,共发现 1207 个 ItemType,其中规则/模板/提示词相关 53 个,核心如下:

| ItemType | 数据量 | 说明 |

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

| Rule | 1 条(空) | 业务规则定义。字段已非常丰富rule_type(list)、target_itemtypes(list)、natural_language_input(ntext)、generated_aml(ntext)、is_activerisk_levelapproval_status 等 |

| Template | 15 条 | AML 创建模板。字段:aml_content(text)、variables(text/JSON)、template_type(list)、template_code(string)、category(list)、status(list)。已有实际数据 |

| Template_Rule_Link | 1 条(空) | 规则与模板的多对多关联。含 source_id/related_id + variable_values(ntext) + template_version + sort_order |

| RuleDefinition | 0 | 规则定义 |

| TemplateDefinition | 0 | 模板定义 |

| RuleExecutionHistory | 0 | 规则执行历史 |

| ItemTypeCreationRule | 0 | 对象创建规则(标准 SCSAI 原生) |

| ItemTypeRepairRule | 0 | 对象修复规则(标准 SCSAI 原生) |

| cfg_Rule / cfg_RuleVariable / cfg_ScopeRule | 0 | 配置规则(标准 SCSAI 原生) |

#### Template 已有 15 条数据详情

| 名称 | category | template_code | status |

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

| 操作 | ObjectClass | Action | Active |

| 窗体 | ObjectClass | Form | Active |

| 角色 | ObjectClass | Identity | Active |

| 对象类创建模板 | ObjectClass | ITEMTYPE_CREATE | Active |

| 对象类创建模板(第二个) | ObjectClass | ITEMTYPE_CREATE | Active |

| Life Cycle Map | ObjectClass | LifeCycleMap | Active |

| List add | ObjectClass | LIST_ADD | 草稿 |

| 方法创建模板 | Method | METHOD_CREATE | Active |

| 方法创建模板(第二个) | Method | METHOD_CREATE | Active |

| 权限 | ObjectClass | Permission | Active |

| 属性添加模板 | Property | PROPERTY_ADD | Active |

| Revision | ObjectClass | Revision | Active |

| 序列 | ObjectClass | Sequence | Active |

| SQL | ObjectClass | SQL | Active |

| 环境变量 | ObjectClass | Varible | Active |

每条 Template 含完整的 aml_content(带 [[variable]] 占位符模板)和部分含 variables(JSON 参数定义,如 [{"name":"method_name","type":"string"}])。

#### ⚠️ 关键结论

SCSAI 服务端现有的 Rule/Template 是标准 SCSAI Innovator 平台管理类型,用于管理 SCSAI 自身的对象创建/修复/方法/权限等,不是 BossAgents SCIOT 业务规则

  • Rule 字段丰富但数据为空(1 条空记录)
  • Template 的 15 条数据是 SCSAI 平台对象(Action/Form/Identity/ItemType/Method/Permission/SQL 等),与 sciot_templates 的 1205 条完全无关
  • BossAgents 的 2,371+1,205+2,817+46 条数据全部在本地 SQLite,SCSAI 上零数据

这意味着分层存储需要 新建自定义 ItemType(BossAgent_Rule/BossAgent_Template/BossAgent_Prompt 等),而非扩展现有 SCSAI 标准 Rule/Template。现有 Rule/Template 的字段设计可作为参考。

1.3 当前的问题瓶颈

#问题后果
1无分层:标准库与用户数据混在 sciot_rules_v2所有人共用,修改即全局生效
2无版本:sciot_rules_v2 无版本字段改了就找不回旧版
3无审核:规则 CRUD 无审批流程误操作直接改变生产行为
4单源耦合:规则/模板/提示词全在本地 SQLiteSCSAI 服务端不可用时也无法离线工作(全断开)
5无用户隔离:当前无 userId 概念无法做个性化规则覆盖

二、目标架构(优化版)

2.1 核心设计原则

  1. SCSAI 为标准库主库——新建自定义 ItemType,所有标准数据集中到 SCSAI 服务端
  2. sciot_import.db 为本地缓存——存储 SCSAI 同步来的标准数据 + 预生成产物
  3. 用户私有库为个性化层——每用户一个 SQLite 库,只存与标准的差异
  4. 优先级:用户修改 > 用户自定义 > 标准副本 > SCSAI 标准 > 回退默认
  5. 双向同步可配置——SCSAI→Local(缓存更新)、Local→User(增量推送)、User→SCSAI(审核提交)

2.2 分层架构图

┌──────────────────────────────────────────────────────────────┐
│  SCSAI 服务端 (114.113.153.234/scplm)                         │
│                                                              │
│  5 个新 ItemType:                     |  参考已有:           │
│  BossAgent_Rule     (字段参考 Rule)   |  Rule (有字段无数据) │
│  BossAgent_Template (字段参考 Template)|  Template (15条数据)│
│  BossAgent_Prompt                     |  Template_Rule_Link  │
│  BossAgent_BizPrompt                  |                      │
│  BossAgent_RuleContribution           |                      │
└──────────┬───────────────────────────────────────────────────┘
           │ AML 查询/创建
           ▼
┌──────────────────────────────────────────────────────────────┐
│  sciot_import.db(本地标准缓存)                               │
│  现有 10 张核心表保持不变                                      │
│  新增 sync_state 表记录同步状态                                 │
│  新增 sync_pending 表记录待写回 SCSAI 的变更                    │
└──────────┬───────────────────────────────────────────────────┘
           │ sync-service 增量同步
           ▼
┌──────────────────────────────────────────────────────────────┐
│  user_library_{userId}.db(用户私有库)                        │
│  ┌────────────────────────────────────────────┐              │
│  │  user_rules     (standard_copy/modified/custom)  │         │
│  │  user_templates (standard_copy/modified/custom)  │         │
│  │  user_prompts   (standard_copy/modified/custom)  │         │
│  │  sync_submissions (待审核)                      │         │
│  │  sync_state       (同步状态)                    │         │
│  └────────────────────────────────────────────┘              │
└──────────┬───────────────────────────────────────────────────┘
           │ 优先级合并
           ▼
┌──────────────────────────────────────────────────────────────┐
│  适配层 (aml.js / rule-engine.js)                             │
│  getEffectiveRules(userId, stdList) → 用户覆盖后列表           │
│  getEffectiveTemplates(userId, stdList)                       │
│  getEffectivePrompts(userId, stdList)                         │
└──────────────────────────────────────────────────────────────┘

三、SCSAI 对象类设计(优化版)

3.1 设计思路变化

v1 方案完全从 SQLite 字段出发设计 ItemType(每个字段对应 SQLite 一列)。

v2 优化

  • 参考 SCSAI 现有 RuleTemplate 的字段设计风格(已有成熟实践)
  • 保持与 SQLite 现有数据的双向映射
  • 利用 SCSAI 原生功能(List/Item 关联/版本管理/权限)

3.2 BossAgent_Rule(2,371 条)

参考 SCSAI 现有 Rule ItemType 的字段模式(natural_language_input + generated_aml 核心对),设计如下:

| 字段名 | SCSAI 类型 | 映射 SQLite 列 | 参考源 |

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

| item_number | string(32, auto) | id | 标准 SCSAI 编号 |

| name | string(256, REQ) | name | Rule.name |

| description | text | description | 通用 |

| bossagent_rule_type | list | rule_type | 参考 Rule.rule_type |

| bossagent_item_type | string(128) | item_type_name | 通用 |

| bossagent_scope | list | scope | 新建 list(validate/create_pre/identify/...)|

| bossagent_severity | list | severity | 新建 list(info/warning/error/hint)|

| bossagent_category | list | category | 新建 list(data/relationship/lifecycle/method/permission/workflow)|

| bossagent_priority | string(10) | priority | P0/P1/P2/P3 |

| bossagent_generated_aml | text | generated_aml | 参考 Rule.generated_aml |

| bossagent_natural_language | text | natural_language | 参考 Rule.natural_language_input |

| bossagent_condition_script | text | condition_script | 参考 Rule.method |

| bossagent_action_type | list | action_type | 新建 list(auto_fix/suggest/block/warn/reference/generate)|

| bossagent_action_config | text | action_config | JSON |

| bossagent_is_active | boolean | is_active | 参考 Rule.is_active |

| bossagent_is_builtin | boolean | is_builtin | 通用 |

| bossagent_source | list | source | 新建 list(generated/builtin/manual/user_contributed)|

| bossagent_version | integer | version | 通用 |

| bossagent_tags | string(512) | tags | 通用 |

| bossagent_hit_count | integer | hit_count | 通用 |

| bossagent_avg_duration | integer | avg_duration_ms | 通用 |

关系bossagent_item_type → ItemType(名称关联)

3.3 BossAgent_Template(1,205 条)

参考 SCSAI 现有 Template ItemType(aml_content + variables + template_code + category 模式):

| 字段名 | SCSAI 类型 | 映射 SQLite 列 | 参考源 |

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

| item_number | string(32, auto) | id | 标准 |

| name | string(128, REQ) | item_type_name | 通用 |

| bossagent_label | string(128) | item_type_label | 通用 |

| bossagent_template_type | list | template_type | 参考 Template.template_type |

| bossagent_category | list | | 参考 Template.category |

| bossagent_aml_content | text | aml_template | 参考 Template.aml_content |

| bossagent_variables | text | llm_fields/auto_fields | JSON,参考 Template.variables |

| bossagent_required_fields | text | required_fields | JSON |

| bossagent_optional_fields | text | optional_fields | JSON |

| bossagent_relationship_types | text | relationship_types | JSON |

| bossagent_lifecycle | string(128) | lifecycle | |

| bossagent_form | string(128) | form | |

| bossagent_generation_rules | text | generation_rules | 完整 JSON |

| bossagent_version | integer | version | |

| bossagent_is_builtin | boolean | is_builtin | |

3.4 BossAgent_Prompt(2,817 条)

字段名SCSAI 类型映射 SQLite 列
item_numberstring(32, auto)id
namestring(256, REQ)name
bossagent_contenttextcontent
bossagent_system_prompttextsystem_prompt
bossagent_item_typestring(128)item_type_name
bossagent_operationlistoperation_type (add/edit/get/generate)
bossagent_scopelistscope
bossagent_versionintegerversion
bossagent_is_builtinbooleanis_builtin
bossagent_variablestextvariables
bossagent_statusliststatus (active/deprecated/testing)

3.5 BossAgent_BizPrompt(46 条)

字段名SCSAI 类型映射 SQLite 列
item_numberstring(32, auto)id
namestring(128, REQ)system_name
bossagent_system_idstring(128)system_id
bossagent_system_prompttextsystem_prompt
bossagent_user_prompttextuser_prompt_template
bossagent_capabilitiestextcapabilities (JSON)

3.6 BossAgent_RuleContribution(审核流程)

字段名SCSAI 类型作用
item_numberstring(32, auto)编号
bossagent_submitterstring(128)提交者(→ Identity)
bossagent_object_typelistrule/template/prompt
bossagent_original_idstring(256)原标准对象 ID
bossagent_contenttext提交内容 JSON
bossagent_descriptiontext提交说明
bossagent_statuslistpending/approved/rejected
bossagent_review_commenttext审核意见

四、同步流程(优化版)

4.1 执行优先级规则

最终生效 = 用户修改版 → 用户自定义 → 标准副本 → SCSAI 标准表 → 回退默认

范例:
  标准库 scope=validate, condition={field:"name", empty}
  用户 A:修改为 {severity: "warning" + scope:"validate"}  → A 生效的是修改版
  用户 B:自建 {scope:"validate", cost < 0}                → B 标准版 + 自建都生效
  用户 C(未同步):直接读标准库                                无明显感知

4.2 初始化同步

Phase 1: SCSAI ItemType 创建
  └── 通过 AML Apply 创建 5 个新 ItemType

Phase 2: 首次全量推入
  ├── 从 sciot_import.db 读取全部数据(2,371 + 1,205 + 2,817 + 46)
  ├── 通过 AML add 批量写入 SCSAI(单次 ≤1MB)
  └── 写入 sync_state 表记录全量同步标记

Phase 3: 首次激活用户库
  ├── 检查 ./data/user_libraries/ 下是否有目标用户库
  ├── 无 → 创建 user_library_{userId}.db
  ├── 从 sciot_import.db 导入标准副本(所有标准数据)
  └── 标记 sync_state (version = current, last_sync = now)

4.3 日常同步(三种模式)

#### 模式 A:SCSAI → Local(缓存刷新)

触发:定时(cron 每日 2:00)或手动
流程:
  1. 查询 SCSAI 上 BossAgent_* 的最后修改时间
  2. 对比本地 sync_state 中记录的版本
  3. 增量更新 sciot_import.db 的对应表
  4. 标记变更字段 → 触发关联提示词重新预生成
  5. 输出统计:N 条更新,M 条新增

#### 模式 B:Local → User(增量推送)

触发:用户登录/手动点击同步
流程:
  1. 读 sciot_import.db 的全部标准数据
  2. 对比 user_library 中 source='standard_copy' 的 id 列表
  3. 补插入新增的标准记录到用户库
  4. 不覆盖用户已修改的记录(modified)
  5. 更新 sync_state.last_sync
  6. 输出:新增 X 条,跳过 Y 条(已修改)

#### 模式 C:User → SCSAI(提交审核)

流程:
  1. 用户标记修改版 → "提交审核"
  2. 写入 user_library.sync_submissions
  3. 管理员在界面上审核(查看 diff → approve/reject)
  4. 审核通过:
     a. 通过 AML add/edit 写入 SCSAI 对应 ItemType
     b. 同步回 local sync_pending
     c. 更新用户库 source = 'approved'
  5. 审核拒绝:
     a. 写回 review_comment
     b. 用户可重新修改后提交

4.4 离线降级

当 SCSAI 不可达时:

| 场景 | 行为 |

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

| SCSAI 宕机 | sciot_import.db 作为标准缓存,只读 |

| 用户库同步 | 不变,仍可用 |

| 规则写入 | 写入 sync_pending 表,SCSAI 恢复后回写 |

| 提交审核 | 暂时不可用(明确提示) |


五、SQLite 用户私有库设计

5.1 存储位置

server/data/user_libraries/
  ├── user_default.db         ← 默认用户(当前无认证体系)
  ├── user_zhangsan.db
  └── ...

5.2 表结构

#### user_rules

| 列 | 类型 | 说明 |

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

| id | TEXT PK | (system_)standard_id |

| rule_data | TEXT | 完整规则 JSON |

| source | TEXT | standard_copy / modified / custom |

| original_id | TEXT | 来源标准 ID(source=modified 时)|

| standard_version | INTEGER | 来源时的标准版本 |

| current_version | INTEGER | 当前版本 |

| synced_to_server | INTEGER | 0/1 |

| sync_status | TEXT | pending / approved / rejected |

| local_modified_at | TEXT | 本地修改时间 |

| sync_comment | TEXT | 提交审核时的说明 |

| created_at | TEXT | |

| updated_at | TEXT | |

#### user_templates(同模式)

#### user_prompts(同模式)

#### sync_submissions

| 列 | 类型 | 说明 |

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

| id | TEXT PK | |

| user_id | TEXT | 提交者 |

| object_type | TEXT | rule/template/prompt |

| object_id | TEXT | 提交的对象 ID |

| original_id | TEXT | 标准 ID(modified 时)|

| before_data | TEXT | 修改前 JSON |

| after_data | TEXT | 修改后 JSON |

| description | TEXT | 提交说明 |

| status | TEXT | pending/approved/rejected |

| review_comment | TEXT | 审核意见 |

| created_at | TEXT | |

| reviewed_at | TEXT | |

#### sync_state(仅 1 行)

| 列 | 类型 | 说明 |

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

| id | TEXT PK | 'global' |

| last_sync_at | TEXT | 上次同步时间 |

| standard_version_rules | INTEGER | 标准规则当前版本号 |

| standard_version_templates | INTEGER | 标准模板当前版本号 |

| standard_version_prompts | INTEGER | 标准提示词当前版本号 |

| sync_source | TEXT | aras / local |

| pending_count | INTEGER | 待写回 SCSAI 的变更计数 |

5.3 三类 source 的行为约束

source可删除可修改可提交审核同步时覆盖
standard_copyNN(→变为 modified)NY(有更新时覆盖)
modifiedYYYN(不覆盖)
customYYN(直接是独立数据)N(无关联)

六、API 设计(优化版)

6.1 新增 API

# 用户私有库
GET    /api/user-library/:userId/stats
GET    /api/user-library/:userId/rules[?source=&scope=&item_type=]
GET    /api/user-library/:userId/rules/:id
POST   /api/user-library/:userId/rules              # 创建/保存
PUT    /api/user-library/:userId/rules/:id          # 修改
DELETE /api/user-library/:userId/rules/:id          # 删除(限 modified/custom)
POST   /api/user-library/:userId/rules/batch        # 批量操作

# 同上模板/提示词
GET    /api/user-library/:userId/templates
PUT    /api/user-library/:userId/templates/:id
...

# 同步
POST   /api/user-library/:userId/sync/init          # 初始化用户库
POST   /api/user-library/:userId/sync/standard[?force=]  # 从标准库增量同步
GET    /api/user-library/:userId/sync/status        # 同步状态

# 审核
POST   /api/user-library/:userId/submit             # 提交审核
GET    /api/user-library/:userId/submissions[?status=]  # 审核列表
PUT    /api/user-library/submissions/:id/approve     # 审核通过(管理员)
PUT    /api/user-library/submissions/:id/reject      # 审核拒绝(管理员)

# 合并数据
GET    /api/user-library/:userId/effective/rules[?scope=&item_type=]
GET    /api/user-library/:userId/effective/templates[?item_type=]
GET    /api/user-library/:userId/effective/prompts[?operation=&item_type=]

6.2 需修改的现有 API

| 现有 API | 改动 |

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

| GET /api/aml/unified/schema/:type | 支持 ?userId= 参数,返回合并版本 |

| GET /api/aml/sciot/rules | 支持 ?userId= 参数 |

| GET /api/rule-engine/rules | 支持 ?userId= 参数 |

| POST /api/rule-engine/pregenerate-prompt | 支持个性化预生成 |

| 前端规则引擎面板 Tab | 增加 "我的规则/模板/提示词" 子面板 |

改动原则:?userId= 不传时行为完全不变(向下兼容)。


七、现有代码改动明细

7.1 新增文件

文件职责行数预估复杂程度
server/services/user-library.js用户库 SQLite 管理、CRUD、优先级合并600★★★
server/services/sync-service.jsSCSAI↔Local↔User 三层同步500★★★★★
server/routes/user-library-routes.js用户库 REST API + 审核 API400★★

7.2 修改文件

文件改动量改动内容
server.js+3 行注册 userLibraryRoutes
server/routes/aml.js+80 行增加 getEffectiveRules() 等合并函数 + 路由可选 userId 参数
server/routes/rule-engine.js+50 行CRUD 支持 userId 转发 + 规则优先级合并
frontend/app.js+200 行规则引擎 Tab 增加 "我的库" 子页面 + 同步按钮 + 提交审核 UI

八、实施阶段(优化版)

Phase 0: 环境确认(30分钟)

  • [x] 0.1 SCSAI 连接正常(已验证:200 OK)
  • [x] 0.2 SCSAI 账号密码有效(root / gyc123456;)
  • [x] 0.3 sciot_import.db 可读
  • [ ] 0.4 确认 5 个新 ItemType 命名不与现有 ItemType 冲突(已确认:不存在)

Phase 1: SCSAI ItemType 创建(1天)

1.1 编写 ItemType 创建脚本

利用现有 server.js 的 proxyArasApi 或直连 AML:

POST http://114.113.153.234/scplm/server/InnovatorServer.aspx
Content-Type: text/xml
SOAPAction: ApplyItem
AUTHUSER: root
AUTHPASSWORD: <MD5("gyc123456;")>

<AML>
  <Item type="ItemType" action="add">
    <name>BossAgent_Rule</name>
    ...
  </Item>
</AML>

1.2 每创建一个 ItemType 后验证(field count / list values)

1.3 全量数据导入

  • 分批从 SQLite 读取(每次 500 条)
  • 组装 AML add XML
  • 调用 SCSAI API 写入
  • 记录写入失败(重试 3 次)

Phase 2: 用户私有库(1天)

2.1 user-library.js

  • SQLite 数据库管理(创建/打开/升级)
  • CRUD 操作(增删改查)
  • 优先级合并 mergeRules(stdRules, userRules)
  • 表结构:user_rules / user_templates / user_prompts / sync_submissions / sync_state

2.2 user-library-routes.js

  • 所有用户库 REST API 路由
  • 参数校验
  • 错误处理

2.3 server.js 注册

const userLibraryRoutes = require('./routes/user-library-routes');
app.use('/api/user-library', userLibraryRoutes);

Phase 3: 适配层(1天)

3.1 getEffectiveRules() 实现逻辑

function getEffectiveRules(userId, scope, itemType) {
  const stdRules = loadFromSciotDb(scope, itemType);
  if (!userId) return stdRules;
  
  const userRules = loadFromUserLib(userId);
  
  // 构建优先级表
  const result = [];
  const overrides = new Map();  // original_id → modified
  
  for (const ur of userRules) {
    if (ur.source === 'modified') overrides.set(ur.original_id, ur);
    if (ur.source === 'custom') result.push(ur.rule_data);
  }
  
  for (const sr of stdRules) {
    if (overrides.has(sr.id)) {
      result.push(overrides.get(sr.id).rule_data);
    } else {
      result.push(sr);
    }
  }
  
  return result;
}

3.2 aml.js / rule-engine.js userId 参数支持

3.3 前端规则引擎 Tab 扩展

Phase 4: 双向同步(2天)

4.1 sync-service.js

  • SCSAI → Local 同步(缓存刷新)
  • Local → User 同步(增量推送)
  • User → SCSAI 提交审核回写

4.2 定时同步

  • cron 每日 2:00 AM → SCSAI → Local 同步
  • 用户登录后自动触发 Local → User 同步

Phase 5: 审核工作流 UI(1天)

5.1 用户私有库子页面(规则/模板/提示词三 Tab)

5.2 差异对比视图(标准 vs 修改版)

5.3 提交审核对话框

5.4 管理员审核面板(待审核/已通过/已拒绝)


九、风险与应对

风险概率影响应对
SCSAI 服务器不可用标准库同步暂停本地缓存直接读 + sync_pending 暂存
AML 批量写入超时首次导入失败分 500 条一批,重试 3 次,记录失败 ID
用户数据冲突优先级混乱clear 的优先级规则 + 日志记录覆盖行为
前端复杂度增加开发周期长Phase 1-3 无前端改动,Phase 5 仅为扩展
标准更新覆盖用户修改用户修改丢失sync 时只插新增,不覆盖 modified

十、不做范围

  • ❌ 不改 sciot_import.db 现有表结构
  • ❌ 不改三条 AML 流水线
  • ❌ 不改前端现有功能面板(仅做 Tab 扩展)
  • ❌ 不影响无用户库需求的用户(?userId= 不传则行为不变)
  • ❌ 不改现有 API 响应格式
  • ❌ 不做用户认证系统(前期固定 userId)
  • ❌ 不做 UI 层面完整的版本对比工具(简化为 JSON diff)

附录:关键文件路径

文件路径
主入口D:/openclaw/bossagents/server.js
AML 路由D:/openclaw/bossagents/server/routes/aml.js
规则引擎D:/openclaw/bossagents/server/routes/rule-engine.js
前端应用D:/openclaw/bossagents/frontend/app.js
config-loaderD:/openclaw/bossagents/config-loader.js
环境变量D:/openclaw/bossagents/.env
标准库 DBD:/openclaw/bossagents/data/sciot_import.db
用户库目录D:/openclaw/bossagents/data/user_libraries/
用户已写草稿D:/openclaw/bossagents/server/services/user-library.js
同步草稿D:/openclaw/bossagents/server/services/sync-service.js
路由草稿D:/openclaw/bossagents/server/routes/user-library-routes.js
原始设计文档D:/openclaw/bossagents/docs/rules-templates-prompts-system.md
SCSAI PLM 集成文档D:/openclaw/bossagents/docs/aras-plm-integration.md

优化要点总结(v1 → v2):

| 方面 | v1 | v2 优化 |

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

| 现状调查 | 基于文档推定 | 实查 SCSAI 服务端 1207 个 ItemType |

| SCSAI 已有数据 | 未提及 | Template 15 条数据 + Rule 字段结构可用 |

| ItemType 设计 | 纯从 SQLite 映射 | 参考了 SCSAI 现有 Rule/Template 字段风格 |

| 同步流程 | 简化描述 | 三种同步模式 + 离线降级 |

| 风险预案 | 无 | 6 项风险及应对 |

| api 设计 | 无 userId 路径 | /api/user-library/:userId/ 标准化 |

| 实施阶段 | 5 步 | 6 步(+环境确认 Phase 0)|

← 返回案例列表
分享:
🤖 Try Now →
🤖
🎁