feat-ui-operation-history-and-durable-execution
Core regression / Python core and release configuration (push) Successful in 17s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 16s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python core and release configuration (push) Successful in 17s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 16s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
4874c7e95a
commit
cf90ced825
44 files changed
+3165
-92
No files matched your search
@@ -0,0 +1,78 @@
|
||||
# Operation History and Durable Resume Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox syntax for tracking.
|
||||
|
||||
**Goal:** Add searchable, clearable operation history and prevent completed operations from replaying on continue/restart.
|
||||
|
||||
**Architecture:** Keep user history and durable execution receipts in separate tables of the task SQLite database. Reuse current command/status validation, owned runtime leases, attempt markers and native recovery. History is an asynchronous Qt page; it never decides execution admission.
|
||||
|
||||
**Tech Stack:** Python, SQLite, PySide6, existing Windows CAD supervisor.
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-11-03-operation-history-execution-design.md`
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Preserve the dirty main workspace; work only in the isolated review worktree.
|
||||
- Do not change DSH functionality, protocols, providers or model tools.
|
||||
- A safe CBB failure continues to later independent engineering tasks; uncertain results stop the queue.
|
||||
- Continue, restart and clear-history never establish a new round or replay verified operations.
|
||||
- Never run real CAD or model requests for verification; use controlled workers and sample projects.
|
||||
|
||||
## Review Focus
|
||||
|
||||
- Missing/corrupt/truncated status or command files must not look like a fresh task.
|
||||
- A crash after worker success but before receipt commit requires reconciliation, never a second replacement.
|
||||
- Retry revisions cannot repackage successful targets into new operations.
|
||||
- Clear confirmation must bind count and global cutoff; new events and execution receipts survive.
|
||||
- First-launch legacy history migration cannot resurrect records after clear.
|
||||
|
||||
### Task 1: History repository and page
|
||||
|
||||
Files: create `history_store.py`, `ui/operation_history.py`, `tests/v1_1/test_operation_history.py`, `tests/ui/test_operation_history_page.py`.
|
||||
|
||||
Interfaces:
|
||||
- `create_history_schema(connection)` is called by StoreSchema inside its transaction.
|
||||
- `HistoryRepository(store).append(task_id, task_name, project_path, operation, state, summary, details, source_key)` returns a global event ID; keyword arguments, details default empty, source_key optional and permanently deduplicated.
|
||||
- `page(query='', state='', before_id=None, limit=100, read_control=None)` returns HistoryPage with `.rows` (tuple of dictionaries), `.next_cursor`, `.total`.
|
||||
- `clear_snapshot()` returns snapshot with `.cutoff_id`, `.count`; `clear(cutoff_id)` clears only that user-history range, retaining source tombstones and completion tables.
|
||||
- `OperationHistoryPage(service,parent=None)` consumes service methods `operation_history_page`, `operation_history_clear_snapshot`, `clear_operation_history`. Exposes `set_active(bool)`, `set_mutations_enabled(bool)`, `shutdown()`.
|
||||
|
||||
- [x] Write failing repository tests for Unicode search, pagination, deduplication, clear-cutoff concurrency, persistence and transaction rollback.
|
||||
- [x] Implement repository and asynchronous page; write UI tests for search, filtering, empty/error states, detail and confirmed/declined clear.
|
||||
- [x] Verify focused tests before integration.
|
||||
|
||||
### Task 2: Conservative incomplete-handoff admission
|
||||
|
||||
Files: modify `quick_run_snapshot.py`, `quick_run.py`; create `handoff_guard.py`, `tests/v1_1/test_resume_evidence.py`.
|
||||
|
||||
Interfaces: `assert_handoff_intact(root,task_id)` rejects missing/malformed/truncated/inconsistent evidence, leaves all bytes untouched. Snapshot returns interrupted evidence instead of executable zero progress.
|
||||
|
||||
- [x] Reproduce missing and truncated command/status cases, normal first prepare and normal resume.
|
||||
- [x] Add service-level preparation and dispatch guards, retaining existing error codes where required.
|
||||
- [x] Verify the original resume probe now blocks missing evidence without extra worker calls.
|
||||
|
||||
### Task 3: Persistent execution receipts
|
||||
|
||||
Files: create `execution_journal.py`, tests; modify `store_schema.py`, `service.py`, `quick_run.py`, `batch.py`, `new_round.py`.
|
||||
|
||||
Interfaces: `ExecutionJournal(store)` owns active rounds, immutable command manifests, per-item attempts, target claims and receipts. QuickRunPreparer receives a journal from its service and carries it through per-task clones. Before worker dispatch it validates/reconciles the frozen plan and claims one attempt; after validated worker result it commits the receipt and its history event before next dispatch. Late/mismatched attempts cannot commit. Snapshot checks journal/file consistency and pauses unfinished attempts.
|
||||
|
||||
- [x] RED/GREEN tests for normal pause/restart, missing evidence, prepared/uncertain attempts, stale callbacks, rollback, retry, new rounds and changed target grouping.
|
||||
- [x] Keep old evidence readable; migrate terminal legacy rows only from validated matching command/status evidence.
|
||||
- [x] Record receipt and history atomically; do not allow history clear to touch admission state.
|
||||
|
||||
### Task 4: Safe failure, history producers and UI integration
|
||||
|
||||
Files: modify `batch.py`, `task_queue.py`, `service.py`, `ui/main_window.py`, `ui/execution_state.py`, `ui/icons.py`, tests.
|
||||
|
||||
- [x] Add failing integration tests: safe failure stops the current CBB's remaining items and runs the next CBB; uncertainty stops all; ordinary continue excludes failed/held tasks; explicit failure retry only retries eligible work.
|
||||
- [x] Integrate the history schema, service calls and top-level navigation, with named controls and preserved task/DSH navigation.
|
||||
- [x] Record actual task/configuration changes and native results, not read-only polling or model suggestions.
|
||||
- [x] Import supported legacy task events once with durable source IDs; clearing does not reimport them.
|
||||
|
||||
### Task 5: Review and verification
|
||||
|
||||
- [x] Run focused safety, history, UI and new-round tests; run the complete project suite and report any skips/failures.
|
||||
- [x] Extend native sample-window acceptance for history/search/clear and 980×700 layout; repeat Chromium glass navigation.
|
||||
- [x] Fresh review of concrete diff against spec; fix critical/important findings with regressions.
|
||||
- [x] Commit and push the existing authorized PR branch, update PR scope/evidence without merging it.
|
||||
@@ -1,6 +1,6 @@
|
||||
# 操作历史与防重复执行:详细执行逻辑
|
||||
|
||||
状态:设计细化,尚未实施。本文延续《operation-history-resume-research》,用户已明确重复执行场景为同一个任务继续或重启后;不修改 DSH 功能。
|
||||
状态:已实施,验证及兼容性决定见 `docs/testing/2026-11-03-operation-history-execution.md`。本文延续《operation-history-resume-research》,用户已明确重复执行场景为同一个任务继续或重启后;不修改 DSH 功能。
|
||||
|
||||
用户已确认:某个 CBB 失败后,只要已经证明没有残留改动且资源已释放,跳过本次失败,继续后面的工程;结果不确定或核验失败时仍停止。
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# 操作历史与持久执行回执验收
|
||||
|
||||
范围:PR #15 的 UI 分支,新增独立操作历史页和同任务逐项执行保护;DSH 源码未改动。验证使用临时工程、受控执行器和原生 Qt 窗口,不调用真实 CAD 或模型。
|
||||
|
||||
## 可复现故障
|
||||
|
||||
原探针中,两个图页、每页两条规则,完成两项后暂停。完整状态下重启共派发四次;删除 `status.tsv` 后重启派发六次,其中两项重复。新回归在状态/命令缺失、空状态、截断或整目录缺失时阻断,原派发次数保持两次。
|
||||
|
||||
安全失败回归:A/B 两工程各四项,A 完成一项后安全失败,余下两项暂缓,B 四项执行,总派发六次。普通继续不增加派发;明确准备 A 重试后增加三次,A 的首项仍仅执行一次。
|
||||
|
||||
## 独立审查与修复
|
||||
|
||||
审查使用独立上下文,检查具体未提交源码及新增文件,发现并修复以下五项:
|
||||
|
||||
1. 精确位号重试使用冻结图页范围,避免用旧料号重新校验成功目标;R1 成功、R2 失败后的重试仅调用 R2。
|
||||
2. 最后一项原生成功但回执未提交时,完成短路前核验证据并补记回执;调用次数保持一次,之后可明确开启新轮次。
|
||||
3. 重试准备以暂存目录、原备份校验、持久转换标记及数据库提交记录发布;备份复制异常回滚原队列,目录切换中断可在重启恢复。
|
||||
4. 恢复使用可重放的审计提交标记。数据库写入异常后再次恢复,`restored_ok`、`retry_ready` 两种情况均不再调用执行器。
|
||||
5. 回执绑定快照、原生报告、原生尝试身份及完整图页语义状态,独立保留证明文件和摘要。恢复下一项前核对最近已核验状态;证据丢失、修改、读取期间变化或缺少保存关闭证明均阻断。
|
||||
|
||||
上述修复均有先失败后通过的回归。原生 VBScript 保护通过 Windows `cscript.exe` 执行提取的生产例程,验证语义差异被阻断、组件枚举顺序不影响比较。
|
||||
|
||||
## 原生窗口
|
||||
|
||||
运行:`python tools/accept_acrylic_ui.py --output build/history-execution-native --webengine-roundtrip --history`。
|
||||
|
||||
Windows 11 build 26200、125% 缩放:操作历史导航、真实配置改动、搜索、详情、Qt 清空确认、清空后任务保留通过;两轮 Chromium 页面往返后毛玻璃和不透明表格隔离通过;降低透明度、分类搜索及 980×700 布局通过。输出 `acceptance.json` 与 `native-app-history*.png`。CAD 启动标记为 false。
|
||||
|
||||
## 测试记录
|
||||
|
||||
- 默认全套第一轮:1229 passed,1 条现有 pywinauto STA 提示。
|
||||
- 定向安全、回执、恢复及 VBScript 例程:123 passed;另补证据读取竞态及缺少关闭证明回归,两项先失败后通过。
|
||||
- 最终默认全套:1233 passed,1 条现有 pywinauto STA 提示,255.82 秒。
|
||||
- 扩展 `tests/trial_task_center tests/dsh tests/packaging tests/integration`:1018 passed、1 skipped;首次另有 1 项旧夹具没有活动图页。补齐夹具并增加语义证明断言后,整个原生会话组 26 passed、1 skipped。跳过项是本机没有 7.9.5 生成的类型库。
|
||||
- 最后修复后的定向组:回执/证据/恢复 54 passed,原生保护 75 passed,并发与界面交接 46 passed。上述组包含扩展运行后新增的中断点和锁序回归。
|
||||
|
||||
边界:没有真实 CAD 工程端到端验收,没有构建或发布 EXE。原生保存、关闭、重开回读仍沿用现有执行器机制,本次增加持久回执、证明绑定和续跑准入。
|
||||
|
||||
## 实施决定
|
||||
|
||||
- 当前独立工程任务采用用户确认的 CBB 失败暂缓策略;旧版未绑定的多工程服务接口保留原有行为,以免改变历史 API 的兼容语义。当前 UI 将这类旧任务作为历史查看。
|
||||
- 真实执行的首次未命中也经过一次完整原生图页只读核验,建立语义基线;不再把仅含料号的发现结果直接升级为完整回执。代价是首次处理未命中页可能多一次只读会话,本轮继续不重复处理。
|
||||
- 本地 `codex/ui-update` 被保留给未提交的其他工作,本次在隔离工作树的 `codex/ui-history-execution` 上提交,再正常推送到已授权的远端 `codex/ui-update`,不触碰主工作区、不合并 PR。
|
||||
|
||||
最终复跑的临时目录调整:C: 空间不足导致 SQLite/pytest 建目录失败;同步工作树内的长临时路径又触发原生资源文件访问拒绝和旧桥接测试辅助脚本的路径限制。最终命令通过进程局部 TEMP/TMP/TMPDIR 以及 `--basetemp` 使用 F: 上独立、无空格的短路径,不改变用户环境。历史集成测试使用唯一搜索标记,避免初始位号配置历史同样包含 R1 时错误断言只有一条匹配。
|
||||
补充并发与恢复验收:
|
||||
|
||||
- 并发回归先复现“服务缓存锁内初始化历史记录、等待数据库锁”的反向锁序,再改为在缓存锁外构造任务服务,仅在短临界区发布缓存。并发/界面交接组 46 passed,DSH 源码未修改。
|
||||
- 恢复提交增加“数据库和文件已经绑定,但最终提交标记尚未删除”的中断点;补记保留原生结果原文,避免重放时把正常文件判为冲突。回执/证据/恢复组 54 passed。
|
||||
- 图页缺失、清单变化或读取异常统一按语义基线冲突处理,不能降级成普通安全失败后越过核验。生产 VBScript 与原生失败保护组 75 passed。
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
- 旧 Part Number 未命中:黄色提示“未命中跳过”,不作替换,自动继续。未命中不等于替换成功。
|
||||
- 旧器件命中:执行原生替换,恢复实例信息,保存并关闭工程,再重新打开核验;核验和关闭完成后才处理下一项。
|
||||
- 目标器件不可用、Part Label 回读失败、保存或核验失败:记录工程、图页、位号和原因,关闭且不保存该失败工程,再继续后续项。结果状态不确定时才停止并要求核验。
|
||||
- 目标器件不可用、Part Label 回读失败、保存或核验失败:记录工程、图页、位号和原因。当前独立工程任务在确认没有残留改动、资源已释放后暂缓本 CBB 余下项,继续后面的独立工程;保存、核验或资源状态不确定时停止整队并要求核验。
|
||||
- 勾选“替换后将 Part Label 写入 Value”才额外改写 Value;未勾选不读取 Part Label,也不额外改写或创建 Value。旧 Value 已存在时,两种模式都继承其位置和显示样式。
|
||||
- 旧 Value 含独立的 `/NC` 段时,两种模式都会把 `/NC` 同步到替换后的 Value 且不重复追加;目标没有 Value 时创建 `/NC` 并继承旧 Value 样式。日志按位号记录替换与同步;工程中的位号本来为空时改用稳定的 `UID=...`,不会输出无法追踪的空白标识。
|
||||
|
||||
@@ -37,3 +37,7 @@
|
||||
`quick-run\quick-part-replace.log` 超过 5 MiB 后保留 3 个轮转备份,单个任务的 `events.jsonl` 超过 5 MiB 后保留 5 个轮转备份。`quick-run-history` 只清理由程序生成且名称可验证的 `batch-*`、`recovery-*`、`sheet-discovery-*` 和 `obsolete-*` 目录;未知目录、链接目录和当前活动的 `quick-run` 证据不会删除。
|
||||
|
||||
历史清理在新的准备、批量或恢复操作进入互斥执行区后运行。默认至少保留最新 10 份历史;其余记录在超过 30 天、总数超过 100 份或总容量超过 5 GiB 时从最旧开始删除。由于最近 10 份始终保留,单个超大工程可能使实际容量暂时高于 5 GiB,此时应人工转存需要长期留档的证据。
|
||||
|
||||
## 操作历史与逐项续跑
|
||||
|
||||
详见[操作历史与继续执行](operation-history.md):搜索及清空历史不会重置完成回执;同一 CBB 部分成功后的失败项重试会保留成功项。
|
||||
@@ -0,0 +1,23 @@
|
||||
# 操作历史与继续执行
|
||||
|
||||
点击顶部的“操作历史”(快捷键 `Ctrl+Shift+H`),查看任务、规则、位号计划的实际保存改动及执行、暂停、恢复结果。可按任务、工程、位号、新旧料号和说明搜索,按结果筛选,选中记录查看详情,点击“更早记录”翻页。搜索、翻页和刷新本身不生成记录。
|
||||
|
||||
“已核验完成”“未命中”“已恢复”“失败”“待核验”分别展示。恢复到旧状态不算替换成功;旧版本没有保存的字段不会补造为真实改动。
|
||||
|
||||
## 清空历史
|
||||
|
||||
“清空全部历史”清理全部历史范围,不受当前搜索条件影响。确认框显示本次清理的记录数;打开确认框后新增的记录保留。默认取消,执行或恢复期间不可清空。
|
||||
|
||||
清空不会删除任务、逐项完成回执、原生证据或工程备份,也不会使已执行项目重新运行。旧版本记录完成首次导入后才允许清空;清空后重启不会重新导入已清理记录。
|
||||
|
||||
## 同一任务继续或重启
|
||||
|
||||
每个独立工程任务保存本轮冻结范围和逐项回执。继续只处理尚未执行的项,不重复派发已完成或已确认未命中的项。只有“开始新一轮”会建立新的轮次。
|
||||
|
||||
续跑检查最近已核验图页的器件身份、属性、布局和连接状态,不拿已经合法修改过的工程与最初文件哈希机械比较。原生证据缺失、损坏或与数据库冲突时停止核验,不把进度归零后重跑。旧证据不足以证明安全时,也需要核验。
|
||||
|
||||
当前界面中的某个 CBB 明确安全失败后,保留失败项,暂缓该工程余下项,并继续后面的独立工程。结果不确定、核验失败或资源未释放时停止整队。普通“继续”不自动重试失败和暂缓项;处理原因并选择“准备失败项重试”后,保留原成功项,只执行失败和暂缓部分。
|
||||
|
||||
重试复用经校验的原始备份,不把已修改工程当作原始副本重新备份。重试队列先暂存、核验再发布;发布中断后重启会恢复原队列。已核验恢复的文件与数据库提交中断时,再次确认恢复会完成原提交,不再次调用替换。
|
||||
|
||||
新数据表随任务数据库自动升级到版本 8。更新前请正常退出工具;本次没有发布新的 EXE,也没有改变 DSH 功能。
|
||||
Reference in new issue
Block a user