6.1 KiB
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 methodsoperation_history_page,operation_history_clear_snapshot,clear_operation_history. Exposesset_active(bool),set_mutations_enabled(bool),shutdown(). -
Write failing repository tests for Unicode search, pagination, deduplication, clear-cutoff concurrency, persistence and transaction rollback.
-
Implement repository and asynchronous page; write UI tests for search, filtering, empty/error states, detail and confirmed/declined clear.
-
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.
- Reproduce missing and truncated command/status cases, normal first prepare and normal resume.
- Add service-level preparation and dispatch guards, retaining existing error codes where required.
- 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.
- RED/GREEN tests for normal pause/restart, missing evidence, prepared/uncertain attempts, stale callbacks, rollback, retry, new rounds and changed target grouping.
- Keep old evidence readable; migrate terminal legacy rows only from validated matching command/status evidence.
- 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.
- 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.
- Integrate the history schema, service calls and top-level navigation, with named controls and preserved task/DSH navigation.
- Record actual task/configuration changes and native results, not read-only polling or model suggestions.
- Import supported legacy task events once with durable source IDs; clearing does not reimport them.
Task 5: Review and verification
- Run focused safety, history, UI and new-round tests; run the complete project suite and report any skips/failures.
- Extend native sample-window acceptance for history/search/clear and 980×700 layout; repeat Chromium glass navigation.
- Fresh review of concrete diff against spec; fix critical/important findings with regressions.
- Commit and push the existing authorized PR branch, update PR scope/evidence without merging it.