Hierarchical Storage and Synchronization of Rules, Templates, and Prompts — Complete Implementation Plan (v2)
1. Current State Overview
1.1 Complete Data Link Overview
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)
#### 数据库内容概要
| Table | Row Count | Content |
|----|------|------|
| sciot_item_types | 928 | Object Class Definitions |
| sciot_properties | 40,854 | Property Definitions |
| sciot_relationships | 587 | Relationship Types |
| sciot_rules_v2 | 2,371 | Rule Engine — scope distribution: 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 | Templates — Categorized by template_type |
| prompt_templates | 2,817 | Prompts — operation_type: add(935)/get(928)/edit(928)/generate(26) |
| sciot_business_prompts | 46 | Business System Prompts |
#### Consumer Side
- Front-end Creation Panel: Read sciot_properties + sciot_rules + sciot_templates → Front-end Self-validation → Front-end Self-assembly → Call SCSAI AML API to Write
- Front-end Rule Engine Panel: 5 functional modules (Rule Management/Template Library/Object Prompts/Business Prompts/AML Assembler), directly CRUD sciot_rules_v2 / prompt_templates / sciot_templates
- AI Workbench / LLM Module: Read prompt_templates to generate structured prompts
1.2 SCSAI Server Status (Actual Investigation)
SCSAI 服务: https://ylxt.chat/scplm
用户: root
Password: gyc123456; ← 注意末尾分号
数据库: SCPLM
#### ✅ 已存在的相关 ItemType
A comprehensive scan of the SCSAI server via the AML API revealed a total of 1207 ItemTypes, of which 53 are related to rules/templates/prompts. The core ones are as follows:
| ItemType | Data Volume | Description |
|----------|--------|------|
| Rule | 1 (empty) | Business rule definition. Fields are already very rich: rule_type(list), target_itemtypes(list), natural_language_input(ntext), generated_aml(ntext), is_active, risk_level, approval_status, etc. |
| Template | 15 entries | AML creation template. Fields: aml_content(text), variables(text/JSON), template_type(list), template_code(string), category(list), status(list). Contains actual data. |
| Template_Rule_Link | 1 (empty) | Many-to-many association between rules and templates. Contains source_id/related_id + variable_values(ntext) + template_version + sort_order |
| RuleDefinition | 0 | Rule definition |
| TemplateDefinition | 0 | Template definition |
| RuleExecutionHistory | 0 | Rule execution history |
| ItemTypeCreationRule | 0 | Object creation rule (standard SCSAI native) |
| ItemTypeRepairRule | 0 | Object repair rule (standard SCSAI native) |
| cfg_Rule / cfg_RuleVariable / cfg_ScopeRule | 0 | Configuration rules (standard SCSAI native) |
#### Template has 15 data entries details
| Name | category | template_code | status |
|------|----------|---------------|--------|
| Operation | ObjectClass | Action | Active |
| Form | ObjectClass | Form | Active |
| Role | ObjectClass | Identity | Active |
| Object Class Creation Template | ObjectClass | ITEMTYPE_CREATE | Active |
| Object Class Creation Template (Second) | ObjectClass | ITEMTYPE_CREATE | Active |
| Life Cycle Map | ObjectClass | LifeCycleMap | Active |
| List add | ObjectClass | LIST_ADD | Draft |
| Method Creation Template | Method | METHOD_CREATE | Active |
| Method Creation Template (Second) | Method | METHOD_CREATE | Active |
| Permission | ObjectClass | Permission | Active |
| Property Addition Template | Property | PROPERTY_ADD | Active |
| Revision | ObjectClass | Revision | Active |
| Sequence | ObjectClass | Sequence | Active |
| SQL | ObjectClass | SQL | Active |
| Environment Variable | ObjectClass | Variable | Active |
Each Template contains complete aml_content (with [[variable]] placeholder template) and some include variables (JSON parameter definitions, e.g., [{"name":"method_name","type":"string"}]).
#### ⚠️ Key Conclusions
The existing Rule/Template in the SCSAI server are standard SCSAI Agent platform management types, used for managing SCSAI's own object creation/repair/methods/permissions, etc., not BossAgents SCIOT business rules.
- Rule fields are extensive but data is empty (1 empty record)
- The 15 records in Template are SCSAI platform objects (Action/Form/Identity/ItemType/Method/Permission/SQL, etc.), completely unrelated to the 1205 records in sciot_templates
- All 2,371+1,205+2,817+46 records of BossAgents data are stored locally in SQLite, zero data on SCSAI
This means hierarchical storage requires creating custom ItemTypes (BossAgent_Rule/BossAgent_Template/BossAgent_Prompt, etc.), not extending the existing standard SCSAI Rule/Template. The field design of the existing Rule/Template can serve as a reference.
1.3 Current Problem Bottlenecks
| # | Problem | Consequence |
|---|---|---|
| 1 | No Layering: Standard library and user data mixed in sciot_rules_v2 | Shared by all, modifications take global effect immediately |
| 2 | No Versioning: sciot_rules_v2 lacks a version field | Cannot retrieve old versions after changes |
| 3 | No Approval: No approval process for rule CRUD | Misoperations directly change production behavior |
| 4 | Single-Source Coupling: Rules/templates/prompts all in local SQLite | Cannot work offline when SCSAI server is unavailable (complete disconnect) |
| 5 | No user isolation: No concept of userId currently | Unable to implement personalized rule overrides |
II. Target Architecture (Optimized Version)
2.1 Core Design Principles
- SCSAI as the standard library master database—create custom ItemTypes, all standard data centralized on the SCSAI server
- sciot_import.db as the local cache—stores standard data synchronized from SCSAI + pre-generated artifacts
- User private library as the personalization layer—one SQLite database per user, storing only differences from the standard
- Priority: User modifications > User customizations > Standard copy > SCSAI standard > Fallback default
- Bidirectional synchronization configurable—SCSAI→Local (cache update), Local→User (incremental push), User→SCSAI (review & submit)
2.2 Layered Architecture Diagram
┌──────────────────────────────────────────────────────────────┐
│ SCSAI 服务端 (ylxt.chat/scplm) │
│ │
│ 5 个新 ItemType: | 参考已有: │
│ BossAgent_Rule (字段参考 Rule) | Rule (有字段无数据) │
│ BossAgent_Template (字段参考 Template)| Template (15条数据)│
│ BossAgent_Prompt | Template_Rule_Link │
│ BossAgent_BizPrompt | │
│ BossAgent_RuleContribution | │
└──────────┬───────────────────────────────────────────────────┘
│ AML 查询/Create
▼
┌──────────────────────────────────────────────────────────────┐
│ 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 optimizations:
- Reference the field design style of existing SCSAI Rules and Templates (proven practice)
- Maintain bidirectional mapping with existing SQLite data
- Leverage SCSAI native features (List/Item association/version management/permissions)
3.2 BossAgent_Rule (2,371 entries)
Referencing the field pattern of existing SCSAI Rule ItemType (natural_language_input + generated_aml core pair), design as follows:
| Field Name | SCSAI Type | Mapped SQLite Column | Reference Source |
|--------|-----------|---------------|--------|
| item_number | string(32, auto) | id | Standard SCSAI Number |
| name | string(256, REQ) | name | Rule.name |
| description | text | description | Generic |
| bossagent_rule_type | list | rule_type | Refer to Rule.rule_type |
| bossagent_item_type | string(128) | item_type_name | Generic |
| bossagent_scope | list | scope | New list (validate/create_pre/identify/...) |
| bossagent_severity | list | severity | New list (info/warning/error/hint) |
| bossagent_category | list | category | New list (data/relationship/lifecycle/method/permission/workflow) |
| bossagent_priority | string(10) | priority | P0/P1/P2/P3 |
| bossagent_generated_aml | text | generated_aml | Refer to Rule.generated_aml |
| bossagent_natural_language | text | natural_language | Refer to Rule.natural_language_input |
| bossagent_condition_script | text | condition_script | Refer to Rule.method |
| bossagent_action_type | list | action_type | New list (auto_fix/suggest/block/warn/reference/generate) |
| bossagent_action_config | text | action_config | JSON |
| bossagent_is_active | boolean | is_active | Refer to Rule.is_active |
| bossagent_is_builtin | boolean | is_builtin | General |
| bossagent_source | list | source | New list (generated/builtin/manual/user_contributed) |
| bossagent_version | integer | version | General |
| bossagent_tags | string(512) | tags | General |
| bossagent_hit_count | integer | hit_count | General |
| bossagent_avg_duration | integer | avg_duration_ms | General |
Relationship: bossagent_item_type → ItemType (name association)
3.3 BossAgent_Template (1,205 records)
Reference the existing SCSAI Template ItemType pattern (aml_content + variables + template_code + category):
| Field Name | SCSAI Type | Mapped SQLite Column | Reference Source |
|--------|-----------|---------------|--------|
| item_number | string(32, auto) | id | Standard |
| name | string(128, REQ) | item_type_name | General |
| bossagent_label | string(128) | item_type_label | General |
| bossagent_template_type | list | template_type | Refer to Template.template_type |
| bossagent_category | list | | Refer to Template.category |
| bossagent_aml_content | text | aml_template | Reference Template.aml_content |
| bossagent_variables | text | llm_fields/auto_fields | JSON, reference 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 | Complete JSON |
| bossagent_version | integer | version | |
| bossagent_is_builtin | boolean | is_builtin | |
3.4 BossAgent_Prompt (2,817 records)
| Field Name | SCSAI Type | Mapped SQLite Column |
|--------|-----------|---------------|
| item_number | string(32, auto) | id |
| name | string(256, REQ) | name |
bossagent_content | text | content
bossagent_system_prompt | text | system_prompt
bossagent_item_type | string(128) | item_type_name
bossagent_operation | list | operation_type (add/edit/get/generate)
bossagent_scope | list | scope
bossagent_version | integer | version
bossagent_is_builtin | boolean | is_builtin
bossagent_variables | text | variables
bossagent_status | list | status (active/deprecated/testing)
3.5 BossAgent_BizPrompt (46 entries)
Field Name | SCSAI Type | Maps to SQLite Column
--------|-----------|---------------
item_number | string(32, auto) | id
name | string(128, REQ) | system_name
bossagent_system_id | string(128) | system_id
bossagent_system_prompt | text | system_prompt
bossagent_user_prompt | text | user_prompt_template
bossagent_capabilities | text | capabilities (JSON)
3.6 BossAgent_RuleContribution (Review Process)
| Field Name | SCSAI Type | Description |
|---|---|---|
| item_number | string(32, auto) | Item Number |
| bossagent_submitter | string(128) | Submitter (→ Identity) |
| bossagent_object_type | list | rule/template/prompt |
| bossagent_original_id | string(256) | Original Standard Object ID |
| bossagent_content | text | Submitted Content JSON |
| bossagent_description | text | Submission Description |
| bossagent_status | list | pending/approved/rejected |
| bossagent_review_comment | text | Review Comment |
IV. Synchronization Process (Optimized Version)
4.1 Execution Priority Rules
最终生效 = 用户修改版 → 用户自定义 → 标准副本 → 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 Create
└── 通过 AML Apply Create 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/ 下是否有目标用户库
├── 无 → Create 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 不可达时:
| Scenario | Behavior |
|------|------|
| SCSAI Down | sciot_import.db serves as standard cache, read-only |
| User Library Sync | Unchanged, still usable |
| Rule Writing | Write to sync_pending table, SCSAI writes back after recovery |
| Submit for Review | Temporarily unavailable (clear prompt) |
V. SQLite User Private Library Design
5.1 Storage Location
server/data/user_libraries/
├── user_default.db ← 默认用户(当前无认证体系)
├── user_zhangsan.db
└── ...
5.2 表结构
#### user_rules
| Column | Type | Description |
|----|------|------|
| id | TEXT PK | (system_)standard_id |
| rule_data | TEXT | Complete Rule JSON |
| source | TEXT | standard_copy / modified / custom |
| original_id | TEXT | Source Standard ID (when source=modified) |
| standard_version | INTEGER | Version of the source standard at the time |
| current_version | INTEGER | Current version |
| synced_to_server | INTEGER | 0/1 |
| sync_status | TEXT | pending / approved / rejected |
| local_modified_at | TEXT | Local modification time |
| sync_comment | TEXT | Description when submitting for review |
| created_at | TEXT | |
| updated_at | TEXT | |
#### user_templates (same pattern)
#### user_prompts (same pattern)
#### sync_submissions
| Column | Type | Description |
|----|------|------|
| id | TEXT PK | |
| user_id | TEXT | Submitter |
| object_type | TEXT | rule/template/prompt |
| object_id | TEXT | ID of the submitted object |
| original_id | TEXT | Standard ID (when modified) |
| before_data | TEXT | JSON data before modification |
| after_data | TEXT | JSON data after modification |
| description | TEXT | Submission description |
| status | TEXT | pending/approved/rejected |
| review_comment | TEXT | Review comment |
| created_at | TEXT | |
| reviewed_at | TEXT | |
#### sync_state (only 1 row)
| Column | Type | Description |
|----|------|------|
| id | TEXT PK | 'global' |
| last_sync_at | TEXT | Last synchronization time |
| standard_version_rules | INTEGER | Current version number of standard rules |
| standard_version_templates | INTEGER | Current version number of standard templates |
| standard_version_prompts | INTEGER | Current version number of standard prompts |
| sync_source | TEXT | SCSAI / local |
| pending_count | INTEGER | Count of pending changes to be written back to SCSAI |
5.3 Behavioral Constraints for Three Types of Sources
| source | Can Delete | Can Modify | Can Submit for Review | Overwritten During Sync |
|---|---|---|---|---|
| standard_copy | N | N (→ becomes modified) | N | Y (overwritten if updates exist) |
| modified | Y | Y | Y | N (not overwritten) |
| custom | Y | Y | N (directly independent data) | N (no association) |
VI. API Design (Optimized Version)
6.1 New APIs
# 用户私有库
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 # Create/Save
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 | Supports ?userId= parameter, returns merged version |
| GET /api/aml/sciot/rules | Supports ?userId= parameter |
| GET /api/rule-engine/rules | Supports ?userId= parameter |
| POST /api/rule-engine/pregenerate-prompt | Supports personalized pre-generation |
| Frontend Rule Engine Panel Tab | Add "My Rules/Templates/Prompts" sub-panel |
Change principle: When ?userId= is not passed, behavior remains completely unchanged (backward compatible).
VII. Details of Existing Code Changes
7.1 New Files
| File | Responsibility | Estimated Lines | Complexity |
|---|---|---|---|
| server/services/user-library.js | User library SQLite management, CRUD, priority merging | 600 | ★★★ |
| server/services/sync-service.js | SCSAI↔Local↔User three-tier synchronization | 500 | ★★★★★ |
| server/routes/user-library-routes.js | User library REST API + Review API | 400 | ★★ |
7.2 Modified Files
| File | Change Volume | Change Content |
|---|---|---|
| server.js | +3 lines | Register userLibraryRoutes |
| server/routes/aml.js | +80 lines | Added getEffectiveRules() and other merge functions + optional userId parameter in routes |
| server/routes/rule-engine.js | +50 lines | CRUD supports userId forwarding + rule priority merging |
| frontend/app.js | +200 lines | Added "My Library" subpage to Rules Engine Tab + Sync button + Submit for Review UI |
VIII. Implementation Phase (Optimized Version)
Phase 0: Environment Verification (30 minutes)
- [x] 0.1 SCSAI connection normal (Verified: 200 OK)
- [x] 0.2 SCSAI account credentials valid (root / gyc123456;)
- [x] 0.3 sciot_import.db is readable
- [ ] 0.4 Confirm 5 new ItemType names do not conflict with existing ItemTypes (Confirmed: No conflicts)
Phase 1: SCSAI ItemType Creation (1 day)
1.1 Write ItemType creation script
Utilize existing proxySCSAIApi in server.js or connect directly to AML:
POST https://ylxt.chat/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 Full data import
- Read from SQLite in batches (500 records each)
- Assemble AML add XML
- Call SCSAI API to write
- Log write failures (retry 3 times)
Phase 2: User Private Library (1 day)
2.1 user-library.js
- SQLite database management (create/open/upgrade)
- CRUD operations (Create, Read, Update, Delete)
- Priority merging mergeRules(stdRules, userRules)
- Table structure: user_rules / user_templates / user_prompts / sync_submissions / sync_state
2.2 user-library-routes.js
- All user library REST API routes
- Parameter validation
- Error handling
2.3 Register in 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 Frontend Rule Engine Tab Extension
Phase 4: Bidirectional Sync (2 days)
4.1 sync-service.js
- SCSAI → Local sync (cache refresh)
- Local → User sync (incremental push)
- User → SCSAI submission approval write-back
4.2 Scheduled Sync
- cron daily at 2:00 AM → SCSAI → Local sync
- Automatically trigger Local → User sync after user login
Phase 5: Approval Workflow UI (1 day)
5.1 User Private Library subpage (three Tabs: Rules/Templates/Prompts)
5.2 Diff comparison view (Standard vs Modified version)
5.3 Submit for approval dialog
5.4 Admin review panel (Pending/Approved/Rejected)
IX. Risks and Mitigation
| Risk | Probability | Impact | Mitigation |
|---|---|---|---|
| SCSAI Server Unavailable | Medium | Standard Library Sync Paused | Read directly from local cache + store in sync_pending |
| AML Batch Write Timeout | Medium | Initial Import Failed | Split into batches of 500, retry 3 times, log failed IDs |
| User Data Conflict | Low | Priority Confusion | Use clear priority rules + log overwrite actions |
| Increased Frontend Complexity | Medium | Long Development Cycle | No frontend changes in Phase 1-3, Phase 5 is for extension only |
| Standard Updates Overwriting User Modifications | Low | User Modifications Lost | During sync, only insert new records, do not overwrite modified ones |
10. Out of Scope
- ❌ Do not modify the existing table structure of sciot_import.db
- ❌ Do not modify the three AML pipelines
- ❌ Do not modify existing frontend functional panels (only Tab extension)
- ❌ Do not affect users without user library requirements (behavior unchanged if ?userId= is not passed)
- ❌ Do not modify existing API response formats
- ❌ Do not implement a user authentication system (use fixed userId initially)
- ❌ Do not build a full UI version comparison tool (simplify to JSON diff)
Appendix: Key File Paths
| File | Path |
|---|---|
| Main Entry | D:/openclaw/bossagents/server.js |
| AML Routes | D:/openclaw/bossagents/server/routes/aml.js |
| Rule Engine | D:/openclaw/bossagents/server/routes/rule-engine.js |
| Frontend Application | D:/openclaw/bossagents/frontend/app.js |
| config-loader | D:/openclaw/bossagents/config-loader.js |
| Environment Variables | D:/openclaw/bossagents/.env |
| Standard Library DB | D:/openclaw/bossagents/data/sciot_import.db |
| User Library Directory | D:/openclaw/bossagents/data/user_libraries/ |
| User Drafts Written | D:/openclaw/bossagents/server/services/user-library.js |
| Sync Drafts | D:/openclaw/bossagents/server/services/sync-service.js |
| Route Drafts | D:/openclaw/bossagents/server/routes/user-library-routes.js |
| Original Design Document | D:/openclaw/bossagents/docs/rules-templates-prompts-system.md |
| SCSAI PLM Integration Document | D:/openclaw/bossagents/docs/SCSAI-plm-integration.md |
Summary of Optimization Points (v1 → v2):
| Aspect | v1 | v2 Optimization |
|------|-----|---------|
| Current State Investigation | Based on document presumption | Actually inspected 1207 ItemTypes on the SCSAI server |
| Existing SCSAI Data | Not mentioned | 15 Template data entries + Rule field structure available |
| ItemType Design | Pure mapping from SQLite | Referenced the existing Rule/Template field style of SCSAI |
| Sync Process | Simplified description | Three sync modes + offline fallback |
| Risk Mitigation Plan | None | 6 risks and countermeasures |
| API Design | No userId path | Standardized /api/user-library/:userId/ |
| Implementation Phases | 5 steps | 6 steps (+ Environment Confirmation Phase 0) |
BossAgents