Skip to content

Commit c98fe41

Browse files
authored
Merge pull request #255 from Integration-Automation/feat/process-mining-batch
Add task/process mining for automation-candidate discovery
2 parents 76c6eb3 + 23f96d5 commit c98fe41

15 files changed

Lines changed: 371 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
## Table of Contents
1515

16+
- [What's new (2026-06-20) — Task / Process Mining (Automation-Candidate Discovery)](#whats-new-2026-06-20--task--process-mining-automation-candidate-discovery)
1617
- [What's new (2026-06-20) — Stuck-Loop Guard (Agent Loop Progress Detection)](#whats-new-2026-06-20--stuck-loop-guard-agent-loop-progress-detection)
1718
- [What's new (2026-06-20) — Coordinate-Space Mapping (Model Grid ⇄ Physical Pixels)](#whats-new-2026-06-20--coordinate-space-mapping-model-grid--physical-pixels)
1819
- [What's new (2026-06-20) — Voice-Command Router](#whats-new-2026-06-20--voice-command-router)
@@ -99,6 +100,12 @@
99100

100101
---
101102

103+
## What's new (2026-06-20) — Task / Process Mining (Automation-Candidate Discovery)
104+
105+
Discover what to automate from recorded action logs. Full reference: [`docs/source/Eng/doc/new_features/v47_features_doc.rst`](docs/source/Eng/doc/new_features/v47_features_doc.rst).
106+
107+
- **`mine_action_log` / `find_repeated_sequences` / `directly_follows` / `rank_automation_candidates`** (`AC_mine_actions`, `ac_mine_actions`): mines a recorded action log for frequent, repeatable command n-grams, builds a directly-follows graph, and ranks automation candidates by `count × length` — the RPA "task mining" pillar AutoControl recorded data for but never analysed. Pure-stdlib; operates on the existing action-list shape; a candidate that recurs and spans several steps is a strong "extract into a skill" signal.
108+
102109
## What's new (2026-06-20) — Stuck-Loop Guard (Agent Loop Progress Detection)
103110

104111
Catch agents stuck in no-progress loops. Full reference: [`docs/source/Eng/doc/new_features/v46_features_doc.rst`](docs/source/Eng/doc/new_features/v46_features_doc.rst).

README/README_zh-CN.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
## 目录
1414

15+
- [本次更新 (2026-06-20) — 任务 / 流程挖掘(自动化候选发现)](#本次更新-2026-06-20--任务--流程挖掘自动化候选发现)
1516
- [本次更新 (2026-06-20) — 卡循环守卫(Agent Loop 进度检测)](#本次更新-2026-06-20--卡循环守卫agent-loop-进度检测)
1617
- [本次更新 (2026-06-20) — 坐标空间映射(模型网格 ⇄ 物理像素)](#本次更新-2026-06-20--坐标空间映射模型网格--物理像素)
1718
- [本次更新 (2026-06-20) — 语音指令路由器](#本次更新-2026-06-20--语音指令路由器)
@@ -98,6 +99,12 @@
9899

99100
---
100101

102+
## 本次更新 (2026-06-20) — 任务 / 流程挖掘(自动化候选发现)
103+
104+
从录制的动作日志发现该自动化什么。完整参考:[`docs/source/Zh/doc/new_features/v47_features_doc.rst`](../docs/source/Zh/doc/new_features/v47_features_doc.rst)
105+
106+
- **`mine_action_log` / `find_repeated_sequences` / `directly_follows` / `rank_automation_candidates`**(`AC_mine_actions``ac_mine_actions`):挖掘录制的动作日志中频繁、可重复的指令 n-gram,建立 directly-follows 图,并依 `count × length` 为自动化候选排名 —— 这是 AutoControl 一直在录数据却从未分析的 RPA「任务挖掘」支柱。纯标准库;作用于既有动作列表结构;一个经常重现且横跨多步的候选,是「抽成 skill」的强烈信号。
107+
101108
## 本次更新 (2026-06-20) — 卡循环守卫(Agent Loop 进度检测)
102109

103110
捕捉卡在无进展循环的 agent。完整参考:[`docs/source/Zh/doc/new_features/v46_features_doc.rst`](../docs/source/Zh/doc/new_features/v46_features_doc.rst)

README/README_zh-TW.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
## 目錄
1414

15+
- [本次更新 (2026-06-20) — 任務 / 流程探勘(自動化候選發現)](#本次更新-2026-06-20--任務--流程探勘自動化候選發現)
1516
- [本次更新 (2026-06-20) — 卡迴圈守衛(Agent Loop 進度偵測)](#本次更新-2026-06-20--卡迴圈守衛agent-loop-進度偵測)
1617
- [本次更新 (2026-06-20) — 座標空間對映(模型網格 ⇄ 實體像素)](#本次更新-2026-06-20--座標空間對映模型網格--實體像素)
1718
- [本次更新 (2026-06-20) — 語音指令路由器](#本次更新-2026-06-20--語音指令路由器)
@@ -98,6 +99,12 @@
9899

99100
---
100101

102+
## 本次更新 (2026-06-20) — 任務 / 流程探勘(自動化候選發現)
103+
104+
從錄製的動作日誌發現該自動化什麼。完整參考:[`docs/source/Zh/doc/new_features/v47_features_doc.rst`](../docs/source/Zh/doc/new_features/v47_features_doc.rst)
105+
106+
- **`mine_action_log` / `find_repeated_sequences` / `directly_follows` / `rank_automation_candidates`**(`AC_mine_actions``ac_mine_actions`):探勘錄製的動作日誌中頻繁、可重複的指令 n-gram,建立 directly-follows 圖,並依 `count × length` 為自動化候選排名 —— 這是 AutoControl 一直在錄資料卻從未分析的 RPA「任務探勘」支柱。純標準函式庫;作用於既有動作清單結構;一個經常重現且橫跨多步的候選,是「抽成 skill」的強烈訊號。
107+
101108
## 本次更新 (2026-06-20) — 卡迴圈守衛(Agent Loop 進度偵測)
102109

103110
捕捉卡在無進展迴圈的 agent。完整參考:[`docs/source/Zh/doc/new_features/v46_features_doc.rst`](../docs/source/Zh/doc/new_features/v46_features_doc.rst)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Task / Process Mining (Automation-Candidate Discovery)
2+
======================================================
3+
4+
Enterprise RPA suites *discover* what to automate by mining recorded desktop
5+
actions for frequent, repeatable sub-sequences. AutoControl records rich action
6+
logs but never analysed them; ``mine_action_log`` turns a log into a ranked list
7+
of automation candidates — it counts repeated command n-grams, builds a
8+
directly-follows graph, and scores candidates by how often **and** how long each
9+
repeated run is.
10+
11+
It operates on the project's action-list shape (each step is a ``["AC_name",
12+
{...}]`` pair or a ``{"command": "AC_name", ...}`` mapping). Pure standard
13+
library (``collections``); imports no ``PySide6``.
14+
15+
Headless API
16+
------------
17+
18+
.. code-block:: python
19+
20+
from je_auto_control import mine_action_log, directly_follows
21+
22+
report = mine_action_log(recorded_actions, min_len=2, max_len=5, min_count=3)
23+
report.total_actions
24+
for cand in report.candidates[:5]: # best first
25+
print(cand.pattern.actions, cand.pattern.count, cand.score)
26+
27+
directly_follows(recorded_actions) # {(a, b): edge_count} flow graph
28+
29+
``find_repeated_sequences`` returns the raw n-gram :class:`SequencePattern` list;
30+
``rank_automation_candidates`` scores them (``count × length`` — more and longer
31+
repeats rank higher). A candidate that recurs often and spans several steps is a
32+
strong "extract this into a reusable skill" signal.
33+
34+
Executor command
35+
----------------
36+
37+
``AC_mine_actions`` takes ``actions`` (a list, or a JSON-string list from the
38+
visual builder) plus ``min_len`` / ``max_len`` / ``min_count`` and returns
39+
``{total_actions, patterns, candidates}``. The same operation is exposed as the
40+
MCP tool ``ac_mine_actions`` and as a Script Builder command under **Report**.

docs/source/Eng/eng_index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Comprehensive guides for all AutoControl features.
6969
doc/new_features/v44_features_doc
7070
doc/new_features/v45_features_doc
7171
doc/new_features/v46_features_doc
72+
doc/new_features/v47_features_doc
7273
doc/ocr_backends/ocr_backends_doc
7374
doc/observability/observability_doc
7475
doc/operations_layer/operations_layer_doc
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
任務 / 流程探勘(自動化候選發現)
2+
================================
3+
4+
企業 RPA 套件透過探勘錄製的桌面動作中頻繁、可重複的子序列來*發現*該自動化什麼。
5+
AutoControl 一直錄製豐富的動作日誌卻從未分析;``mine_action_log`` 將日誌轉成一份排序後
6+
的自動化候選清單 —— 它計數重複的指令 n-gram、建立 directly-follows 圖,並依每段重複執
7+
行的**次數與長度**為候選評分。
8+
9+
它作用於本專案的動作清單結構(每步為 ``["AC_name", {...}]`` 對或 ``{"command":
10+
"AC_name", ...}`` 對映)。純標準函式庫(``collections``);不匯入 ``PySide6``。
11+
12+
無頭 API
13+
--------
14+
15+
.. code-block:: python
16+
17+
from je_auto_control import mine_action_log, directly_follows
18+
19+
report = mine_action_log(recorded_actions, min_len=2, max_len=5, min_count=3)
20+
report.total_actions
21+
for cand in report.candidates[:5]: # 由高至低
22+
print(cand.pattern.actions, cand.pattern.count, cand.score)
23+
24+
directly_follows(recorded_actions) # {(a, b): 邊計數} 流程圖
25+
26+
``find_repeated_sequences`` 回傳原始的 n-gram :class:`SequencePattern` 清單;
27+
``rank_automation_candidates`` 為其評分(``count × length`` —— 越多、越長的重複排名越
28+
高)。一個經常重現且橫跨多步的候選,是「把它抽成可重用 skill」的強烈訊號。
29+
30+
執行器指令
31+
----------
32+
33+
``AC_mine_actions`` 接受 ``actions``(清單,或視覺化建構器傳入的 JSON 字串清單)以及
34+
``min_len`` / ``max_len`` / ``min_count``,並回傳 ``{total_actions, patterns,
35+
candidates}``。相同操作亦提供為 MCP 工具 ``ac_mine_actions``,以及 Script Builder 中
36+
**Report** 分類下的指令。

docs/source/Zh/zh_index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ AutoControl 所有功能的完整使用指南。
6969
doc/new_features/v44_features_doc
7070
doc/new_features/v45_features_doc
7171
doc/new_features/v46_features_doc
72+
doc/new_features/v47_features_doc
7273
doc/ocr_backends/ocr_backends_doc
7374
doc/observability/observability_doc
7475
doc/operations_layer/operations_layer_doc

je_auto_control/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@
259259
from je_auto_control.utils.loop_guard import (
260260
LoopGuard, LoopVerdict, default_loop_guard, digest_result,
261261
)
262+
# Task/process mining: automation-candidate discovery from action logs
263+
from je_auto_control.utils.process_mining import (
264+
Candidate, MiningReport, SequencePattern, directly_follows,
265+
find_repeated_sequences, mine_action_log, rank_automation_candidates,
266+
)
262267
# Background popup/interrupt watchdog (unattended automation)
263268
from je_auto_control.utils.watchdog import (
264269
PopupWatchdog, WatchdogRule, default_popup_watchdog,
@@ -715,6 +720,9 @@ def start_autocontrol_gui(*args, **kwargs):
715720
"VoiceCommand", "VoiceRouter", "default_voice_router",
716721
"CoordinateSpace", "downscale_png", "normalized_space", "xga_space",
717722
"LoopGuard", "LoopVerdict", "default_loop_guard", "digest_result",
723+
"Candidate", "MiningReport", "SequencePattern", "directly_follows",
724+
"find_repeated_sequences", "mine_action_log",
725+
"rank_automation_candidates",
718726
# MCP server
719727
"AuditLogger", "HttpMCPServer", "MCPContent", "MCPPrompt",
720728
"MCPPromptArgument", "MCPResource", "MCPServer", "MCPTool",

je_auto_control/gui/script_builder/command_schema.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,17 @@ def _add_misc_specs(specs: List[CommandSpec]) -> None:
10561056
fields=(),
10571057
description="Clear the default loop guard's history.",
10581058
))
1059+
specs.append(CommandSpec(
1060+
"AC_mine_actions", "Report", "Mine Action Log",
1061+
fields=(
1062+
FieldSpec("actions", FieldType.STRING,
1063+
placeholder='[["AC_click_mouse", {}], ...]'),
1064+
FieldSpec("min_len", FieldType.INT, optional=True, default=2),
1065+
FieldSpec("max_len", FieldType.INT, optional=True, default=5),
1066+
FieldSpec("min_count", FieldType.INT, optional=True, default=3),
1067+
),
1068+
description="Find repeated sequences + rank automation candidates.",
1069+
))
10591070
specs.append(CommandSpec(
10601071
"AC_generate_sop", "Report", "Generate SOP Document",
10611072
fields=(

je_auto_control/utils/executor/action_executor.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3229,6 +3229,22 @@ def _loop_guard_reset() -> Dict[str, Any]:
32293229
return {"reset": True}
32303230

32313231

3232+
def _mine_actions(actions: Any, min_len: int = 2, max_len: int = 5,
3233+
min_count: int = 3) -> Dict[str, Any]:
3234+
"""Adapter: mine an action log for repeated, automatable sequences."""
3235+
from je_auto_control.utils.process_mining import mine_action_log
3236+
report = mine_action_log(_coerce_list(actions), min_len=min_len,
3237+
max_len=max_len, min_count=min_count)
3238+
return {
3239+
"total_actions": report.total_actions,
3240+
"patterns": [{"actions": list(p.actions), "count": p.count}
3241+
for p in report.patterns],
3242+
"candidates": [{"actions": list(c.pattern.actions),
3243+
"count": c.pattern.count, "score": c.score}
3244+
for c in report.candidates],
3245+
}
3246+
3247+
32323248
class Executor:
32333249
"""
32343250
Executor
@@ -3503,6 +3519,7 @@ def __init__(self):
35033519
"AC_to_model": _to_model,
35043520
"AC_loop_guard_observe": _loop_guard_observe,
35053521
"AC_loop_guard_reset": _loop_guard_reset,
3522+
"AC_mine_actions": _mine_actions,
35063523
"AC_a11y_record_start": _a11y_record_start,
35073524
"AC_a11y_record_stop": _a11y_record_stop,
35083525
"AC_a11y_record_events": _a11y_record_events,

0 commit comments

Comments
 (0)