Files
dxdesigner-part-replacement/docs/superpowers/plans/2026-10-30-lifecycle-optimization.md
T

86 lines
5.0 KiB
Markdown

# Lifecycle Optimization Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Make CAD save, close, exit, and resource-release outcomes explicit and recoverable across normal, failed, cancelled, and forced-stop paths.
**Architecture:** Keep business completion and infrastructure cleanup as separate outcomes. Extend the existing resource journal and runtime result objects with phase evidence, give owned helper processes a bounded natural-exit window, and preserve cleanup failures instead of converting them into a successful-looking result.
**Tech Stack:** Python 3.12, PySide6, pywin32, pytest, existing `BatchCadRuntime`, `IsolatedCadSession`, supervisor protocol, and VBS worker evidence files.
**Spec:** Approved in chat on 2026-10-30 as Phase 1 of the project optimization.
## Global Constraints
- Preserve the existing no-replay protection for uncertain project mutations.
- Never terminate an unowned process or clear evidence that cannot be verified.
- Keep normal successful replacement behavior and public service method signatures compatible.
- Every production change must have a regression test that fails before the change.
---
### Task 1: Model and persist separate save/close evidence
**Files:**
- Modify: `src/dx_productivity/trial_task_center/batch_runtime.py`
- Modify: `src/dx_productivity/trial_task_center/isolated_cad.py`
- Modify: `src/dx_productivity/trial_task_center/batch_resources.py`
- Test: `tests/v1_1/test_batch_runtime.py`
- Test: `tests/v1_1/test_isolated_cad.py`
**Interfaces:**
- Consumes existing CAD shutdown records and project checkpoints.
- Produces journal fields for save requested, save returned, readback verified, project closed, and cleanup outcome.
- [ ] **Step 1: Write failing tests** for a close failure after a save request and for a cleanup record that reports business completion with infrastructure failure.
- [ ] **Step 2: Run the focused tests** and verify they fail because the current record has no separate save evidence and the completed result hides cleanup failure.
- [ ] **Step 3: Add the smallest evidence fields** with backward-compatible defaults and preserve the existing uncertain/recovery guard.
- [ ] **Step 4: Run the focused tests** and verify both pass.
- [ ] **Step 5: Run the related supervisor and recovery tests** before moving to the next task.
### Task 2: Allow owned helper processes a bounded natural exit window
**Files:**
- Modify: `src/dx_productivity/trial_task_center/isolated_desktop.py`
- Test: `tests/v1_1/test_isolated_desktop.py`
- Test: `tests/v1_1/test_batch_runtime_windows.py`
**Interfaces:**
- Consumes owned process identities and existing Win32 job cleanup records.
- Produces cleanup records that distinguish naturally exited descendants from forced termination.
- [ ] **Step 1: Write a failing test** where the root CAD process has exited and an owned helper exits shortly afterward; assert no forced termination is requested.
- [ ] **Step 2: Run the test** and verify the current implementation calls the force cleanup immediately.
- [ ] **Step 3: Add a bounded wait** only for identities whose owned root has already exited; retain force cleanup after the deadline.
- [ ] **Step 4: Run the focused Windows tests** and verify the cleanup record includes the wait and final state.
- [ ] **Step 5: Run the resource release test group**.
### Task 3: Separate diagnostic journal failures from the CAD Quit protocol
**Files:**
- Modify: `src/dx_productivity/trial_task_center/isolated_cad.py`
- Modify: `src/dx_productivity/trial_task_center/batch_release_log.py`
- Test: `tests/v1_1/test_isolated_cad.py`
- Test: `tests/v1_1/test_batch_runtime.py`
**Interfaces:**
- Consumes the existing owned CAD identity and project-close state.
- Produces an explicit diagnostic-write warning while still attempting a valid Quit sequence.
- [ ] **Step 1: Write a failing test** that injects a closing-record write failure and asserts Quit is still attempted when project state is safe.
- [ ] **Step 2: Run the test** and verify Quit is currently skipped.
- [ ] **Step 3: Isolate diagnostic persistence errors** from the normal Quit decision and record both outcomes.
- [ ] **Step 4: Run the focused tests** and verify both normal and failed-record paths.
- [ ] **Step 5: Run all lifecycle and supervisor tests**.
### Task 4: Verify the phase and document field validation
**Files:**
- Modify: `docs/testing/2026-10-26-application-lifecycle-investigation.md`
- Create: `docs/testing/2026-10-30-phase1-lifecycle-optimization.md`
- [ ] **Step 1: Run the complete test suite** and capture the count and warnings.
- [ ] **Step 2: Run `python -m compileall -q src` and `git diff --check`.**
- [ ] **Step 3: Record the exact scenarios covered and the remaining real DxDesigner field checks.**
- [ ] **Step 4: Review the final diff for accidental changes outside Phase 1.**