senclaw/rule-engine

app Luồng xử lý dữ liệu dạng đồ thị: kéo-thả node, nối cổng vào/ra, chạy realtime. Nguồn (webhook, lịch cron, kích hoạt tay) bơm sự kiện vào chuỗi node lọc — rẽ nhánh — biến đổi — gọi HTTP/AI/thông báo. Mỗi node khai báo nhiều cổng ra (true/false, success/failed, N nhánh switch) và nhiều cổng vào có thể gộp (join/merge). Có debug trace từng bước.

Install

senclaw app install senclaw/rule-engine

Verifies sha512 and SenClaw’s signature before writing to disk.

Documentation

Rule Engine — SenClaw Space App

Luồng xử lý dữ liệu dạng đồ thị: node nguồn bơm sự kiện, các node lọc / rẽ nhánh / biến đổi nối với nhau qua cổng có tên, mỗi cạnh mang một bản sao dữ liệu.

Port 4550. MCP server rule-engine-mcp tại /api/mcp/sse.

Đây là bản viết lại bằng Rust của dipper-hub/services/engine-runner (Go) và thư viện lõi dipper-engine. Thiết kế và lý do khác bản gốc: [docs/rule-engine-app-design.md](../../docs/rule-engine-app-design.md).


Khác biệt cốt lõi so với bản Go

dipper-engine (Go)app này
Định tuyếnrule tự đọc id node kế tiếp từ option rồi ghi vào Next []stringrule phát ra tên cổng; engine tra bảng edges
Cổng raquy ước đặt tên field (next_success, next_true, map_switch), mỗi rule một kiểu; maping.go chỉ hiểu 3 trường hợpRuleSpec khai báo cổng, có cả cổng động (switch)
Cổng vàokhông có — 2 cạnh vào 1 node = node chạy 2 lầnjoin / merge với barrier, có TTL
Cổng lỗirule quên set Next → nhánh chết im lặngcổng error ngầm định cho mọi node; không nối thì vẫn ghi log
Hàng đợi1 queue cho mỗi loại rule1 mailbox cho mỗi node, concurrency riêng
Vòng đờiSession vĩnh viễn, EndCount đếm sai, Infinity() khiến không bao giờ kết thúcRun cho mỗi sự kiện, kết thúc khi hết message in-flight
TimeoutTimeoutSession: 30 bị ép thành 30 nanosecond và không ai đọcjoin TTL + run TTL + trần số bước, đều cấu hình được
Dữ liệumap[string]interface{} chia sẻ giữa các nhánh fan-out (data race)serde_json::Value, deep clone tại điểm fan-out
DừngRule.Stop() không bao giờ được gọiSourceRule::stop được gọi khi gỡ luồng

Chạy khi phát triển

cargo run -p rule-engine                 # backend :4550
cd apps/rule-engine/web && npm run dev   # UI dev server, proxy /api
cargo test -p rule-engine                # test

Đăng ký với daemon (daemon thấy port 4550 đã healthy sẽ dùng lại tiến trình của bạn thay vì spawn bản khác):

curl -X POST http://127.0.0.1:18788/api/space/apps/register-local \
  -H 'content-type: application/json' \
  -d '{"path":"/Users/benji/Projects/SemaClaw/apps/rule-engine"}'

Đóng gói: ./scripts/pack.shrule-engine-app.zip.

Mô hình

nguồn ──out──▶ ┌────────┐ ──true──▶ ...
               │  node  │ ──false─▶ ...
   ──in──────▶ └────────┘ ──error─▶ ...
  • Chain — đồ thị đã lưu. ACTIVE thì được nạp và chạy.
  • Run — một sự kiện chảy qua đồ thị. Kết thúc khi không còn message nào đang bay không còn barrier nào đang chờ.
  • Hop — một bước trong run. Chỉ ghi lại khi bật debug.
  • Message{ data, meta }. data là payload phẳng; meta là thông tin kèm theo (nguồn, headers, thời điểm). Biểu thức thấy data ở tầng trên cùng và meta dưới tên meta_data.

Nhiều cổng vào

Mặc định (opts.join = "any") mỗi message vào node là một lần chạy độc lập — đúng như engine Go. Đổi thành:

  • "all" — chờ đủ một message trên mỗi cổng vào đang được nối, chạy một lần với { "<tên cổng>": <data> }
  • "merge" — như trên nhưng deep-merge thành một object

Barrier gom theo (run, node, thế hệ), hoặc theo opts.corrKey nếu muốn gom theo một giá trị nghiệp vụ. Quá joinTimeoutMs thì nhánh bị huỷ và ghi log — không treo im lặng.

Danh mục node

Gọi GET /api/registry (hoặc MCP rule_registry) để lấy danh sách đầy đủ kèm cổng và JSON Schema cấu hình. Nhóm chính:

  • Nguồnmanual, webhook, schedule, telegram-poll
  • Logicconditional, switch, fork, join, merge, trigger-time
  • Biến đổiarithmetic, format, project, delay, split
  • Lọc có statemoving-average, kalman
  • Đíchhttp-request, telegram-send, notification, log, mcp-call, senclaw-send
  • AIai-agent (bridge SenClaw / persona / provider trực tiếp), knowledge

REST

GET /api/statussức khoẻ + số liệu
GET /api/registrydanh mục node cho UI
GET/POST /api/chainsliệt kê / tạo
GET/PATCH/DELETE /api/chains/:idchi tiết / sửa metadata / xoá
PUT /api/chains/:id/graphthay toàn bộ đồ thị
POST /api/chains/:id/validate|activate|deactivate|trigger
GET /api/chains/:id/runs|logslịch sử
GET /api/runs/:id/hopstrace từng bước
DELETE /api/chains/:id/statexoá state của node lọc
GET /api/eventsSSE realtime (hop / log / trạng thái run)
POST /api/hooks/:webhookIdingress cho node webhook

Biến môi trường

mặc định
PORT4550
RULE_ENGINE_DATA_DIR~/.senclaw/space-app-data/rule-enginenằm ngoài thư mục cài, vì cài lại zip sẽ xoá sạch app_dir
RULE_ENGINE_JOIN_TIMEOUT_MS60000hạn mặc định của barrier
RULE_ENGINE_MAX_HOPS10000trần số bước mỗi run, chặn vòng lặp vô tận
RULE_ENGINE_RUN_TTL_SECS900run quá hạn bị thu hồi
SENCLAW_BASE_URLhttp://127.0.0.1:18788daemon, cho bridge LLM/knowledge

Giới hạn đã biết

  • Bridge llm.request **không có temperature** (daemon hard-code 0.2). Node ai-agent chỉ cho chỉnh nó ở backend provider (gọi thẳng nhà cung cấp).
  • finish == "length" được coi là lỗi, không phải kết quả — câu trả lời cụt sẽ ra cổng error thay vì đi tiếp với JSON gãy.
  • Bridge mcp.call của core vẫn là stub, nên node mcp-call POST thẳng vào /api/mcp/message của app đích.
  • Nhóm node IoT của Dipper (input-telemetry, output-model, get-last-model…) chưa có — chúng phụ thuộc bảng device/model của dipper-hub. Xem §10 của design doc.

Declared permissions

{
  "network": [
    "127.0.0.1"
  ],
  "exec": [
    "./rule-engine"
  ]
}

Declared by the publisher, not enforced by SenClaw. The CLI compares this against what you already have installed and asks before anything widens.

Published by

@senclawtrusted
benji
44 packages · 0 downloads · member since 2026-07 · GitHub since 2015-06

The checkmark means SenClaw confirmed who this publisher is. It says nothing about whether their packages are safe.

About

Owner@senclaw
Latest1.0.0
Downloads (30d)0
Repositorygithub.com/NortonBen/senclaw-app

Versions

VersionTagsArtifactsPublished
1.0.0latestdarwin-arm64, linux-x64, win32-x642026-08-07

Artifacts · 1.0.0

PlatformFormatSignatureFileSize
darwin-arm64zipunsignedrule-engine-app.zip3543 KB
linux-x64zipunsignedrule-engine-app.zip3991 KB
win32-x64zipunsignedrule-engine-app.zip3910 KB

Unsigned builds require sign-in to download and are not distributed to the auto-updater, because unsigned executables from a new domain get flagged as unsafe. Sign and notarize (macOS) or Authenticode-sign (Windows) to distribute publicly.

Auto-update endpoints

For a Tauri app — add to tauri.conf.json:

"endpoints": ["https://senclaw.bacnd.com/api/v1/updates/tauri/senclaw/rule-engine/{{target}}/{{arch}}/{{current_version}}"]

For an electron-updater app — generic provider URL:

https://senclaw.bacnd.com/updates/senclaw/rule-engine/stable

Only signed/notarized artifacts are offered as updates — a client fetches the update without credentials, and unsigned binaries are not publicly downloadable.

Something wrong with this package?

Report this package

Report this package

Tell us what is wrong and a moderator will look at it. Be specific — a report that names a version and a behaviour can be checked in minutes; one that says “looks sketchy” cannot be acted on at all.

Not about this package? Contact us instead. What happens to a report is described in reporting and moderation.

API: GET https://senclaw.bacnd.com/api/v1/packages/senclaw/rule-engine