My Error Log

My Error Log

Record mistakes made during debugging to avoid repeating them

Last Updated: 2026-05-31


Error 1: Violated v3.2 architecture by calling backend rule engine in Create panel

Error Description

In the Create process of StaffCapabilities.vue, I added code calling /api/rule-engine/execute/create_pre, which violates the v3.2 architectural design.

Error Code

// 我错误添加的代码(已撤销)
const ruleEngineResp = await fetch('/api/rule-engine/execute/create_pre', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({...})
})

为什么错

根据 rules-templates-prompts-system.md v3.2 架构:

  • For Create scenarios, the process is now handled autonomously by the frontend; it should no longer call the backend rule engine's /api/rule-engine/create-item or /api/rule-engine/execute/*.
  • Frontend responsibilities: Field correction → AML assembly → SCSAI submission
  • Backend responsibilities only: SQLite data storage/retrieval + SCSAI transparent proxy

Correct Approach

The Create panel should:

  1. Call /api/aml/unified/schema/:type to fetch the Schema
  2. Call /api/sciot/type-template/:type to fetch the template
  3. Call /api/aml/sciot/prompts to fetch prompts
  4. Frontend sanitizeProperties() performs field correction
  5. Frontend buildAML() assembles the AML
  6. Frontend _SCSAIApiRequest() submits to SCSAI

Fix

The erroneous code has been reverted, restoring the implementation compliant with the v3.2 architecture.


Error 2: Modified code without carefully reading the documentation

Error Description

Modified the code without fully understanding the v3.2 architecture described in rules-templates-prompts-system.md.

Why it's wrong

  • Document v3.2 clearly states the architectural changes for the Create scenario.
  • I didn't first carefully read the "5.2 Scenario 1: Create (Object Creation)" section of the document.
  • Seeing "Rule Engine" led me to assume I needed to call the rule engine API, failing to understand the architectural evolution.

Correct Approach

Before making any changes, you must first read the relevant documentation, especially:

  1. The architecture section in rules-templates-prompts-system.md
  2. The comments in the code to be modified (StaffCapabilities.vue lines 1624-1628 explicitly state the architectural principle).
  3. First examine the current state, understand the existing implementation, then decide if modification is needed.

Error 3: Confused the responsibilities of different panels

Error Description

Assumed all panels should call the rule engine, confusing the distinction between the Create panel and other panels.

Why it's wrong

| Panel | Architecture | Calls Rule Engine? |

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

| Create | v3.2 Frontend Autonomous | ❌ Does not call |

| Repair | v3.2 Rule Engine | ✅ Calls /api/rule-engine/repair |

| Optimize | v3.2 Rule Engine | ✅ Calls /api/rule-engine/optimize |

| Compare | v3.2 Rule Engine | ✅ Calls /api/rule-engine/compare |

| Identify | v3.2 Rule Engine | ✅ Call /api/rule-engine/identify |

The Create panel is special; v3.2 explicitly changed it to be handled autonomously by the frontend.


My Improvement Measures

  1. Check Documentation Before Modifying
  • First read rules-templates-prompts-system.md
  • Understand the Architectural Design Intent
  • Confirm if the current code aligns with the architecture
  1. Inspect Before Modifying
  • Use the Task/Explore tool to check the current state
  • Understand the current implementation logic
  • Identify areas that need modification
  1. Verify After Modification
  • Verify that the modifications comply with the architecture
  • Build tests
  • Do not add features arbitrarily
  1. Ask when uncertain
  • Do not guess architectural intent
  • When unsure, ask for clarification before proceeding

Key Document Sections Memo

v3.2 Create Scenario Architecture (Must Remember)

调用链(v3.2 架构):
  前端 Create 面板(StaffCapabilities.vue: runCreate())
    → Step 1: GET /api/aml/unified/schema/:type  → 获取对象Schema
    → Step 2: GET /api/sciot/type-template/:type → 获取模板
    → Step 3: GET /api/aml/sciot/prompts         → 获取预生成的提示词
    → Step 4: 构建 Prompt
    → Step 5: POST /api/llm/chat                 → 调用大模型
    → Step 6: 前端完成全部业务逻辑(不调用后端规则引擎)
      6.1 sanitizeProperties()     → 字段修正
      6.2 分离 item_properties
      6.3 _SCSAIApiRequest()        → 预创建嵌套 Item
      6.4 补充默认值
      6.5 buildAML()               → 前端组装AML
      6.6 _SCSAIApiRequest()        → SubmitSCSAI

核心原则:后端只负责 SQLite 数据存取 + SCSAI 透明代理,前端负责全部业务逻辑。



Error 4: Directly executing action_script (backend new Function)

Error Description

Using new Function('context', 'rule', 'options', rule.action_script) in the backend rule engine to directly execute the action_script from the database. Also documented an "architectural exception" allowing this.

Why It's Wrong

  • SCSAI client JS is deeply bound to the UI and cannot be executed directly without the UI environment.
  • action_script is a rule description transformed from analyzing and understanding client-side methods, not executable code.
  • Direct execution may be incorrect due to the lack of UI context.

Correct Approach

  • Client method → Analyze and understand → Convert into rule definition (condition + action_type + action_config)
  • Frontend obtains the rule definition and implements the corresponding frontend logic based on the rules
  • action_script serves only as a reference document for the rule's intent

Fix

  • Reverted the code in StaffCapabilities.vue that called /api/rule-engine/execute/create_pre
  • Corrected the description of "Architectural Exception" in the documentation

Error 5: Repeatedly violating architectural principles

Error Description

Repeatedly making the same mistake on the same issue:

  1. First: Unauthorized addition of a call to the backend rule engine
  2. Second: After reverting, understood the v3.2 architecture
  3. Third: Added a call to the backend rule engine again ("Architectural Exception")
  4. Fourth: Was informed that action_script cannot be executed directly

Root Cause

  • Did not truly understand the conversion process of "Client method → Rule definition → Frontend self-implementation"
  • Saw the rule engine API and wanted to call it without considering the intent of the architectural design

Correct Understanding

SCSAI客户端JS方法(与UI绑定,不可直接执行)
    ↓ 分析理解
规则定义(condition + action_type + action_config + action_script描述)
    ↓ 存入数据库
前端获取规则定义
    ↓ 根据规则自己编写逻辑
前端实现(sanitizeProperties、buildAML等)

Current Code State (Corrected)

  • ✅ Create panel complies with v3.2 architecture (frontend completes independently)
  • ✅ Does not call the backend /api/rule-engine/execute
  • ✅ action_script serves only as a reference document, not for direct execution
  • ✅ Frontend sanitizeProperties() implements field correction independently
  • ✅ Frontend buildAML() implements AML assembly independently
← 返回案例列表

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