Industry Extension Playbook

Industry Extension Playbook

Goal: Enable the 3rd, 4th, Nth industry beyond 'Machinery (High-end)' to implement the full chain of 'Knowledge Base → Structuring → Base Layer Governance → Digital Staff Business Loop' via a configuration-driven, zero-code-change approach.

Complete the full-chain implementation of 'Knowledge Base → Structuring → Base Layer Governance → Digital Staff Business Loop'.

First implementation case: Phosphorus Chemical Industry (phos_chem), baseline at the end of the document.


0. Flywheel Overview

① 知识库采集/沉淀         ② 结构化抽取            ③ 基础层治理            ④ 数字员工闭环
kb-pipeline-run.cjs   →   process/bom 碎片   →   kb-govern-base.cjs   →   kb-staff-loop.cjs
(kb_docs 万级)             (110k 级,质量粗)        (base 库,零空字段)      (7 员工自我运维)
                                                       │
                                                       └─→ ⑤ 质量规则(R1-R8)注册进规则引擎
                                                            统一入口: Digital Staff + 规则引擎双通道

四个阶段各自独立、可单跑;加新行业时第 ③④⑤ 步只需一份 JSON 配置 + 跑脚本。


1. What to Do to Add a New Industry (3-Minute Version)

| # | Action | Related Files | Description |

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

| 1 | Create Industry Configuration | config/industry-ext/.json | 8 families × (Process Sequence + Hierarchical BOM + Fragment Aggregation Type) |

| 2 | Run Governance | node scripts/kb-govern-base.cjs --industry | Outputs three tables in server/data/kb/_base.db |

| 3 | Run Loop | node scripts/kb-staff-loop.cjs (LOOP_INDUSTRY=) | 7 staff actions: identify/create/inspect/compare/fix/optimize/generate |

| 4 | Validate | 'Acceptance Criteria' below | Target metrics met + Zero P0 quality rule violations |

No changes to any .js business code are required. If the industry knowledge base already exists in Step ②, collection can be skipped and governance can proceed directly.


2. Industry Configuration (config/industry-ext/.json)

Structure

{
  "industryId": "phos_chem",            // 行业 id,与知识库 industry_id 一致
  "seedPrefix": "kb_doc_pc_",           // 手工 seed 工艺的 source_ref 前缀(可选,用于优质底座)
  "families": [                          // 主干家族列表(N 个)
    {
      "code": "WPA",                     // 家族编码
      "name": "湿法磷酸(二水法)",        // 家族名称
      "desc": "硫酸分解磷矿制取湿法磷酸…", // 家族描述
      "fragTypes": ["氧化","结晶","萃取"], // 碎片聚合:按 process_type 关键词归并真实参数
      "steps": [                          // 有序工序序列
        {
          "name": "磷矿粉磨与调浆",
          "seed": "湿法磷酸-磷矿粉磨",      // 优先匹配 seed 工艺(真实参数),可省略
          "domain": {                      // 标准知识兜底(真实数据缺失时使用,打 domain_std 标签)
            "intent": "磨细至-200目",
            "equip": ["球磨机","水力旋流器","调浆槽"],
            "params": [{ "label": "磨矿细度", "value": "80-100", "unit": "%通过200目" }],
            "safety": "防粉尘爆炸"
          }
        }
      ],
      "bom": {                            // 层级 BOM:产品线 → 原料/主设备/辅助设备/产品/副产物 → 物料
        "RAW":  [ { "material": "磷矿石", "spec": "", "qty": 1000, "unit": "吨/天" } ],
        "EQ":   [ { "material": "萃取反应槽", "spec": "", "qty": 2, "unit": "台" } ],
        "AUX":  [ { "material": "循环泵", "spec": "", "qty": 4, "unit": "台" } ],
        "PROD": [ { "material": "湿法磷酸", "spec": "P2O5 28-32%", "qty": 2500, "unit": "吨/天" } ],
        "BYP":  [ { "material": "磷石膏", "spec": "", "qty": 5000, "unit": "吨/天" } ]
      }
    }
  ]
}

数据纪律

  • steps[].seed 命中 → 用 seed 真实参数(最优)
  • 否则 steps[].domain → 标准知识占位(src=domain_std)
  • 参数不足 2 条时 → 用 fragTypes 从碎片库聚合真实参数(src=fragment)
  • 可选 GOV_USE_LLM=1 → LLM 补全占位(src=llm,deepseek-v4-flash,429 自动退避)

3. 治理脚本(scripts/kb-govern-base.cjs)

把碎片收敛成「行业可用的基础工艺规程 + 层级化基础 BOM」。

node scripts/kb-govern-base.cjs --industry phos_chem          # 基础治理(无 LLM,可复现)
GOV_USE_LLM=1 node scripts/kb-govern-base.cjs --industry phos_chem  # LLM 增强(补 domain_std 占位)
GOV_OUT=C:/xx/out.db  …                                       # 可选:输出到指定路径

产出:server/data/kb/_base.db

| 表 | 内容 | 质量要求 |

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

| base_process_spec | N basic process specifications | Each includes a description |

| base_process_step | Process sequence for each specification | Parameters/equipment/safety zone src tags |

| base_bom | Three-level hierarchical BOM | Usage non-empty, role non-empty, hierarchy non-isolated |

Source Tags (Traceable)

| src | Meaning |

|---|---|

| seed | Manually seeded real parameters (optimal) |

| fragment | Real parameters aggregated from fragment library |

| llm | LLM Completion (deepseek-v4-flash, only when GOV_USE_LLM=1) |

| domain_std | Standard Engineering Knowledge Fallback (insufficient real data) |

Write Guarantee: wal_checkpoint(TRUNCATE) before script shutdown + reopen database after shutdown to read and print actual persisted data count [Write Verification].

If the verification count does not match expectations (historical cases of DCP loss in 7/8 families), rerun the process.


4. Digital Staff Business Loop (scripts/kb-staff-loop.cjs)

Using the base database as asset input, execute the self-operation and maintenance closed loop for 7 core digital staff roles:

DS-SCSAI-001 Identify → DS-SCSAI-001 Create → DS-STAT-001 巡检
→ DS-ECR-001 Compare → DS-PROC-DATA-001 Repair → DS-PROCESS-OPT-001 Optimize → DS-CONTENT-001 Generate
node scripts/kb-staff-loop.cjs                                   # 只读闭环(Identify+巡检+Compare+Repair+Optimize+Generate)
LOOP_WRITE_BACK=1 node scripts/kb-staff-loop.cjs                  # 创建员工回写主库(幂等,source_ref=governed_base)
LOOP_INDUSTRY=baijiu node scripts/kb-staff-loop.cjs               # 换行业

每个员工做真实的事

| 员工 | 动词 | 真实产出 |

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

| DS-SCSAI-001 | Identify | Asset Inventory (Procedure Count/Process Step Count/BOM Item Count/Source Distribution) |

| DS-SCSAI-001 | Create | Asset Cataloging + (LOOP_WRITE_BACK=1) Write-back to Master Process/BOM, with traceability and rollback capability |

| DS-STAT-001 | Inspect | R1-R8 Quality Rule Scan (Parameters/Equipment/Safety/Dosage/Roles/Hierarchy/Duplicates/JSON) |

| DS-ECR-001 | Compare | Base Database vs. Master Database Governance Write-back Layer Quantity Consistency |

| DS-PROC-DATA-001 | Repair | Missing Dosage → Suggested Value Based on Non-zero Mean for Same Family & Role (Persisted after manual confirmation) |

| DS-PROCESS-OPT-001 | Optimize | Optimization Directions for Main Process Temperature Control Interlocks/Cycle Time/HAZOP |

| DS-CONTENT-001 | Generate | -base-report.md (Procedure Details + Three-Level BOM + Optimization Suggestions) |


5. Quality Rules Integration into Rule Engine (Unified Entry)

server/core/industry-quality-rules.js —— Industry-agnostic quality rules, defined once, consumed via dual channels:

server/core/industry-quality-rules.js
   ├─ inspectBaseDb(baseDbPath)     → R1-R8 巡检,统一 {ruleId,severity,item,count,samples}
   └─ suggestRepairs(baseDbPath)    → 用量缺失修复推导(同家族同角色均值,autoApply=false)
        │
        ├─ 通道1 CapabilityRuntime.inspect/repair     ← Digital Staff DS-STAT-001/DS-PROC-DATA-001
        │    参数带 industry / industry_base_db 即触发
        └─ 通道2 RuleEngine.executeInspect            ← 规则引擎统一巡检入口
             item_type=IndustryBase 或带行业参数即触发,rule_id 对齐规则表

规则集 R1-R8

| 规则 ID | 内容 | 级别 |

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

| inspect-industry-r1 | Process Parameter is Empty | warning |

| inspect-industry-r2 | Process Equipment is Empty | warning |

| inspect-industry-r3 | Process safety constraint is empty | warning |

| inspect-industry-r4 | BOM material usage quantity is missing | warning |

| inspect-industry-r5 | BOM role is missing | warning |

| inspect-industry-r6 | BOM level is isolated | error |

| inspect-industry-r7 | BOM material is duplicated | warning |

| inspect-industry-r8 | Process parameter JSON is corrupted | error |

Rules have been registered into sciot_rules_v2 (scope=inspect, item_type_name=IndustryBase) and are visible, can be enabled/disabled in the rule management interface.


6. Acceptance Criteria

MetricPass ThresholdCheck Command
Basic Process Specifications≥ 5 entries (main families)SELECT COUNT(*) FROM base_process_spec
Process coverageAt least 3 steps per procedureSELECT COUNT(*) FROM base_process_step
BOM quantity non‑null100%SELECT COUNT(*) FROM base_bom WHERE level=2 AND (qty IS NULL OR qty=0) = 0
BOM role non‑null100%SELECT COUNT(*) FROM base_bom WHERE role IS NULL OR role='' = 0
BOM level non‑isolated100%SELECT COUNT(*) FROM base_bom WHERE level=2 AND parent_id NOT IN (SELECT id FROM base_bom WHERE level=1) = 0
Quality rule inspection0 error (R6/R8 not triggered)node -e call inspectBaseDb or run closed‑loop③
Closed Loop7/7 Successnode scripts/kb-staff-loop.cjs last line
Idempotent Write-backNo duplicate increments on re-runRun twice with LOOP_WRITE_BACK=1, governed_base count unchanged

7. Phosphorus Chemical Baseline (First Implementation, 2026-08-21)

ItemValue
Industryphos_chem
FamiliesWPA/TPA/YP/MAP/DAP/PG/STPP/DCP (8 main lines)
Base Libraryserver/data/kb/phos_chem_base.db: 8 specs / 29 processes / 127 BOM lines (79 material items)
Source Ratioseed 49 / fragment 25 / llm 24 / domain_std 65 (≈60% real endorsement)
Main Library Write-back29 processes (source_ref=governed_base:) + 79 BOMs (entry_id=GB-)
Reportdocs/industry-ext/phos_chem-base-report.md

8. Known Boundaries / Next Steps

  • LLM Endpoint: llm-extract.js getConfig() fixed to prioritize reading LLM_* (sensenova gateway + deepseek-v4-flash); this endpoint has 429 TPM throttling, governance script implements 25s exponential backoff. GOV_USE_LLM=1 enables regular runs.
  • Fragment Layer vs. Base Layer: 110k fragment layer retained (broad coverage), base layer is governed, usable assets; the two are separated.
  • Next Candidates:
  1. Continuously merge fragment layer by family (periodic LLM re-governance, flywheel effect);
  2. After digital employee "Create" writes back to main library, automatically trigger knowledge base retrieval coverage (RAG pipeline connected);
  3. Add baijiu / electronics industry configurations to verify template replicability.
← 返回案例列表

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