Skip to content

Commit 03e9243

Browse files
committed
Add flow checkpoint/resume (durable execution) and py.typed marker
1 parent 98fcbc5 commit 03e9243

17 files changed

Lines changed: 447 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 8 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-19) — Checkpoint & Resume](#whats-new-2026-06-19--checkpoint--resume)
1617
- [What's new (2026-06-19) — i18n / l10n Testing](#whats-new-2026-06-19--i18n--l10n-testing)
1718
- [What's new (2026-06-19) — Data Quality](#whats-new-2026-06-19--data-quality)
1819
- [What's new (2026-06-19) — SBOM & Suite Sharding](#whats-new-2026-06-19--sbom--suite-sharding)
@@ -73,6 +74,13 @@
7374

7475
---
7576

77+
## What's new (2026-06-19) — Checkpoint & Resume
78+
79+
Durable execution for long flows + a `py.typed` marker, full stack. Full reference: [`docs/source/Eng/doc/new_features/v21_features_doc.rst`](docs/source/Eng/doc/new_features/v21_features_doc.rst).
80+
81+
- **Flow checkpoint & resume** — `run_resumable(actions, run_id=..., store=...)` / `CheckpointStore` (`AC_run_resumable` / `AC_checkpoint_status` / `AC_checkpoint_clear`, `ac_*`): persist step-index + variables after each step; on re-run with the same `run_id`, fast-forward past completed steps and rehydrate variables — a flow that crashes at step 400 resumes at 400, not 0. Pluggable (SQLite default), cleared on completion.
82+
- **`py.typed` marker** — ships the PEP 561 marker so Mypy/Pyright/Pylance honor AutoControl's inline type hints in downstream code (the repo's typed API was previously invisible to type checkers).
83+
7684
## What's new (2026-06-19) — i18n / l10n Testing
7785

7886
Three pure-stdlib internationalization/localization testing helpers that compound, full stack. Full reference: [`docs/source/Eng/doc/new_features/v20_features_doc.rst`](docs/source/Eng/doc/new_features/v20_features_doc.rst).

‎README/README_zh-CN.md‎

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

1313
## 目录
1414

15+
- [本次更新 (2026-06-19) — 检查点与续跑](#本次更新-2026-06-19--检查点与续跑)
1516
- [本次更新 (2026-06-19) — i18n / l10n 测试](#本次更新-2026-06-19--i18n--l10n-测试)
1617
- [本次更新 (2026-06-19) — 数据质量](#本次更新-2026-06-19--数据质量)
1718
- [本次更新 (2026-06-19) — SBOM 与测试分片](#本次更新-2026-06-19--sbom-与测试分片)
@@ -72,6 +73,13 @@
7273

7374
---
7475

76+
## 本次更新 (2026-06-19) — 检查点与续跑
77+
78+
长流程的耐久执行 + `py.typed` 标记,走完整五层。完整参考:[`docs/source/Zh/doc/new_features/v21_features_doc.rst`](../docs/source/Zh/doc/new_features/v21_features_doc.rst)。
79+
80+
- **流程检查点与续跑** — `run_resumable(actions, run_id=..., store=...)` / `CheckpointStore`(`AC_run_resumable` / `AC_checkpoint_status` / `AC_checkpoint_clear`、`ac_*`):每步后持久化 step-index + 变量;以相同 `run_id` 再执行时快进略过已完成步骤并还原变量——在第 400 步崩溃的流程会从 400 续跑,而非从 0。可抽换(默认 SQLite),完成后清除。
81+
- **`py.typed` 标记** — 附带 PEP 561 标记,让 Mypy/Pyright/Pylance 在下游代码采用 AutoControl 的内嵌类型注解(此前类型化 API 对类型检查器是隐形的)。
82+
7583
## 本次更新 (2026-06-19) — i18n / l10n 测试
7684

7785
三项可互相搭配的纯标准库国际化/本地化测试辅助工具,走完整五层。完整参考:[`docs/source/Zh/doc/new_features/v20_features_doc.rst`](../docs/source/Zh/doc/new_features/v20_features_doc.rst)。

‎README/README_zh-TW.md‎

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

1313
## 目錄
1414

15+
- [本次更新 (2026-06-19) — 檢查點與續跑](#本次更新-2026-06-19--檢查點與續跑)
1516
- [本次更新 (2026-06-19) — i18n / l10n 測試](#本次更新-2026-06-19--i18n--l10n-測試)
1617
- [本次更新 (2026-06-19) — 資料品質](#本次更新-2026-06-19--資料品質)
1718
- [本次更新 (2026-06-19) — SBOM 與測試分片](#本次更新-2026-06-19--sbom-與測試分片)
@@ -72,6 +73,13 @@
7273

7374
---
7475

76+
## 本次更新 (2026-06-19) — 檢查點與續跑
77+
78+
長流程的耐久執行 + `py.typed` 標記,走完整五層。完整參考:[`docs/source/Zh/doc/new_features/v21_features_doc.rst`](../docs/source/Zh/doc/new_features/v21_features_doc.rst)。
79+
80+
- **流程檢查點與續跑** — `run_resumable(actions, run_id=..., store=...)` / `CheckpointStore`(`AC_run_resumable` / `AC_checkpoint_status` / `AC_checkpoint_clear`、`ac_*`):每步後持久化 step-index + 變數;以相同 `run_id` 再執行時快轉略過已完成步驟並還原變數——在第 400 步當掉的流程會從 400 續跑,而非從 0。可抽換(預設 SQLite),完成後清除。
81+
- **`py.typed` 標記** — 附帶 PEP 561 標記,讓 Mypy/Pyright/Pylance 在下游程式碼採用 AutoControl 的內嵌型別註記(此前型別化 API 對型別檢查器是隱形的)。
82+
7583
## 本次更新 (2026-06-19) — i18n / l10n 測試
7684

7785
三項可互相搭配的純標準庫國際化/在地化測試輔助工具,走完整五層。完整參考:[`docs/source/Zh/doc/new_features/v20_features_doc.rst`](../docs/source/Zh/doc/new_features/v20_features_doc.rst)。
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
==================================================
2+
New Features (2026-06-19) — Checkpoint & Resume
3+
==================================================
4+
5+
Durable execution for long action lists, plus a ``py.typed`` marker so the
6+
package's inline type hints are honored by type checkers. Pure standard
7+
library; wired through the full stack (facade, ``AC_*`` executor commands,
8+
MCP tools, Script Builder).
9+
10+
.. contents::
11+
:local:
12+
:depth: 2
13+
14+
15+
Flow checkpoint & resume
16+
=======================
17+
18+
A multi-hour unattended flow that dies at step 400 should not restart from
19+
zero. :func:`run_resumable` persists ``{run_id, step_index, variables}``
20+
after each executed step to a pluggable store; on a later run with the same
21+
``run_id`` it fast-forwards past completed steps and rehydrates the script
22+
variables::
23+
24+
from je_auto_control import run_resumable, CheckpointStore
25+
26+
store = CheckpointStore("runs.db")
27+
result = run_resumable(actions, run_id="nightly-invoices", store=store)
28+
result["resumed_from"] # 0 on a fresh run, N when resuming after a crash
29+
30+
On normal completion the checkpoint is cleared. The store is injectable, so
31+
resume is unit-tested deterministically without a real crash:
32+
``CheckpointStore.save`` / ``load`` / ``clear``.
33+
34+
Executor / MCP commands:
35+
36+
* ``AC_run_resumable`` — run ``actions`` with checkpoint/resume keyed by
37+
``run_id`` (persisted to ``db``).
38+
* ``AC_checkpoint_status`` — the saved checkpoint for a run (or null).
39+
* ``AC_checkpoint_clear`` — delete a run's checkpoint.
40+
41+
(and the matching ``ac_run_resumable`` / ``ac_checkpoint_status`` /
42+
``ac_checkpoint_clear`` MCP tools).
43+
44+
45+
``py.typed`` marker
46+
==================
47+
48+
The package now ships a PEP 561 ``py.typed`` marker, so Mypy / Pyright /
49+
Pylance honor AutoControl's inline type annotations in downstream code —
50+
completing the value of the typed public API. No code change for callers;
51+
just better editor autocompletion and type checking out of the box.

‎docs/source/Eng/eng_index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Comprehensive guides for all AutoControl features.
4343
doc/new_features/v18_features_doc
4444
doc/new_features/v19_features_doc
4545
doc/new_features/v20_features_doc
46+
doc/new_features/v21_features_doc
4647
doc/ocr_backends/ocr_backends_doc
4748
doc/observability/observability_doc
4849
doc/operations_layer/operations_layer_doc
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
==========================================
2+
新功能 (2026-06-19) — 檢查點與續跑
3+
==========================================
4+
5+
長動作清單的耐久執行(durable execution),並新增 ``py.typed`` 標記讓
6+
型別檢查器採用套件的內嵌型別註記。純標準庫;走完整五層(facade、
7+
``AC_*`` 執行器指令、MCP 工具、Script Builder)。
8+
9+
.. contents::
10+
:local:
11+
:depth: 2
12+
13+
14+
流程檢查點與續跑
15+
================
16+
17+
跑了數小時、卻在第 400 步當掉的無人值守流程,不該從頭重來。
18+
:func:`run_resumable` 在每執行完一步後,把 ``{run_id, step_index,
19+
variables}`` 存入可抽換的儲存後端;之後以相同 ``run_id`` 再執行時,會
20+
快轉略過已完成的步驟並還原腳本變數::
21+
22+
from je_auto_control import run_resumable, CheckpointStore
23+
24+
store = CheckpointStore("runs.db")
25+
result = run_resumable(actions, run_id="nightly-invoices", store=store)
26+
result["resumed_from"] # 全新執行為 0;當機後續跑則為 N
27+
28+
正常完成後檢查點會被清除。儲存後端可注入,因此續跑邏輯可在不真的當機的
29+
情況下做決定性單元測試:``CheckpointStore.save`` / ``load`` / ``clear``。
30+
31+
執行器 / MCP 指令:
32+
33+
* ``AC_run_resumable`` — 以 ``run_id`` 為鍵,帶檢查點/續跑執行 ``actions``
34+
(存到 ``db``)。
35+
* ``AC_checkpoint_status`` — 某次執行已存的檢查點(或 null)。
36+
* ``AC_checkpoint_clear`` — 刪除某次執行的檢查點。
37+
38+
(以及對應的 ``ac_run_resumable`` / ``ac_checkpoint_status`` /
39+
``ac_checkpoint_clear`` MCP 工具)。
40+
41+
42+
``py.typed`` 標記
43+
=================
44+
45+
套件現在附帶 PEP 561 的 ``py.typed`` 標記,讓 Mypy / Pyright / Pylance
46+
在下游程式碼中採用 AutoControl 的內嵌型別註記——讓型別化的公開 API 真正
47+
發揮價值。呼叫端無需改動;開箱即享更好的編輯器自動完成與型別檢查。

‎docs/source/Zh/zh_index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ AutoControl 所有功能的完整使用指南。
4343
doc/new_features/v18_features_doc
4444
doc/new_features/v19_features_doc
4545
doc/new_features/v20_features_doc
46+
doc/new_features/v21_features_doc
4647
doc/ocr_backends/ocr_backends_doc
4748
doc/observability/observability_doc
4849
doc/operations_layer/operations_layer_doc

‎je_auto_control/__init__.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@
161161
from je_auto_control.utils.i18n_test import (
162162
check_catalog, check_overflow, pseudo_localize, pseudo_localize_catalog,
163163
)
164+
# Flow checkpoint & resume (durable execution for long action lists)
165+
from je_auto_control.utils.checkpoint import (
166+
Checkpoint, CheckpointStore, run_resumable,
167+
)
164168
# Background popup/interrupt watchdog (unattended automation)
165169
from je_auto_control.utils.watchdog import (
166170
PopupWatchdog, WatchdogRule, default_popup_watchdog,
@@ -583,6 +587,7 @@ def start_autocontrol_gui(*args, **kwargs):
583587
"extract_fields", "mask_rows", "validate_rows",
584588
"check_catalog", "check_overflow", "pseudo_localize",
585589
"pseudo_localize_catalog",
590+
"Checkpoint", "CheckpointStore", "run_resumable",
586591
# MCP server
587592
"AuditLogger", "HttpMCPServer", "MCPContent", "MCPPrompt",
588593
"MCPPromptArgument", "MCPResource", "MCPServer", "MCPTool",

‎je_auto_control/gui/script_builder/command_schema.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,28 @@ def _add_misc_specs(specs: List[CommandSpec]) -> None:
660660
_add_memory_specs(specs)
661661
_add_data_quality_specs(specs)
662662
_add_i18n_specs(specs)
663+
_add_checkpoint_specs(specs)
664+
665+
666+
def _add_checkpoint_specs(specs: List[CommandSpec]) -> None:
667+
run_id = FieldSpec("run_id", FieldType.STRING)
668+
db = FieldSpec("db", FieldType.FILE_PATH)
669+
specs.append(CommandSpec(
670+
"AC_run_resumable", "Flow", "Run Resumable (checkpoint)",
671+
fields=(run_id, db),
672+
description="Run 'actions' (JSON view) with checkpoint/resume keyed "
673+
"by run_id; resumes past completed steps after a crash.",
674+
))
675+
specs.append(CommandSpec(
676+
"AC_checkpoint_status", "Flow", "Checkpoint: Status",
677+
fields=(run_id, db),
678+
description="Return the saved checkpoint for a run (step + variables).",
679+
))
680+
specs.append(CommandSpec(
681+
"AC_checkpoint_clear", "Flow", "Checkpoint: Clear",
682+
fields=(run_id, db),
683+
description="Delete a run's checkpoint.",
684+
))
663685
specs.append(CommandSpec(
664686
"AC_wcag_audit", "Accessibility", "WCAG 2.2 Conformance Audit",
665687
fields=(

‎je_auto_control/py.typed‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# PEP 561 marker: this package ships inline type information.

0 commit comments

Comments
 (0)