Files
dxdesigner-part-replacement/docs/superpowers/plans/2026-10-30-reliable-supervision.md

5.1 KiB

Reliable Supervision 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 batch execution produce durable diagnostics and deterministic forced-stop outcomes when Windows workers or private desktop cleanup fail.

Architecture: Add a small lifecycle/evidence writer shared by worker and supervisor. Keep business result validation separate from transport and resource cleanup; classify missing results from recorded process evidence. Make forced stop durable and idempotent before terminating the owned Job Object.

Tech Stack: Python 3.12, PySide6, pywin32, Windows Job Objects, pytest.

Spec: docs/superpowers/specs/2026-10-30-reliable-supervision-design.md

Global Constraints

  • Never automatically replay a write operation after an uncertain or missing result.
  • Preserve existing task/business result formats and UI recovery actions.
  • Use atomic file replacement for durable JSON records.
  • Windows-specific tests must remain isolated from real DxDesigner projects.

Task 1: Durable lifecycle and process evidence

Files:

  • Create: src/dx_productivity/trial_task_center/supervisor_evidence.py

  • Modify: src/dx_productivity/trial_task_center/batch_worker.py

  • Modify: src/dx_productivity/trial_task_center/batch_supervisor.py

  • Test: tests/v1_1/test_supervisor_evidence.py

  • Write tests for durable lifecycle append, bounded stdout/stderr capture, and typed missing-result diagnostics.

  • Run ..\\..\\.venv\\Scripts\\python.exe -m pytest -q tests/v1_1/test_supervisor_evidence.py; observe the new tests fail because the evidence API is absent.

  • Implement LifecycleEvidence.append(event, **fields), try_append, write_process_evidence, and typed errors with from_directory. JSON uses existing flush/fsync/replace; JSONL tolerates incomplete final lines. Stream tails are bounded in UTF-8 bytes when persisted.

  • Make the worker append startup, business completion, result commit, and exception events; preserve the existing result files.

  • Make the supervisor record process exit code and bounded output and use evidence when result files are missing.

  • Run the focused evidence tests and then the existing supervisor protocol tests.

Task 2: Deterministic forced-stop precedence

Files:

  • Modify: src/dx_productivity/trial_task_center/batch_supervisor.py

  • Reuse unchanged: src/dx_productivity/trial_task_center/stop_control.py

  • Reuse unchanged: src/dx_productivity/trial_task_center/supervisor_result.py

  • Test: tests/v1_1/test_safe_user_stop.py

  • Add failing tests proving protection-write failure preserves a forced-stop state, transport callback failure does not downgrade a confirmed force, and repeated force requests are idempotent.

  • Observe missing forced-state evidence, duplicate termination, and raw late-write PermissionError before implementing fixes.

  • Persist forced intent before protection and termination, classify protection/termination confirmation separately, and return user_forced_stop only after Job termination is confirmed.

  • Preserve primary_error, existing BOM diagnostics, and cleanup evidence, including simultaneous cleanup and confirmation persistence errors.

  • Run all safe-stop and supervisor-result tests.

Task 3: Windows process membership and cleanup evidence

Files:

  • Modify: src/dx_productivity/trial_task_center/isolated_desktop.py

  • Reuse unchanged: src/dx_productivity/trial_task_center/batch_resources.py

  • Test: tests/v1_1/test_isolated_desktop.py

  • Test: tests/v1_1/test_desktop_diagnostics.py

  • Add suspended-start membership and real worker PID/venv identity tests; retain existing PID plus creation-time and desktop-release mismatch tests.

  • Reproduce launcher PID differing from actual worker PID; captured stderr identifies the admission rejection.

  • Normalize only the current non-frozen venv interpreter launch; verify Job assignment before resume and persist existing cleanup/accounting snapshots.

  • Verify and reuse existing strict post-release enumeration and durable release proof; no desktop-release rewrite is needed after the identity fix.

  • Run the focused Windows resource tests.

Task 4: Regression and operator documentation

Files:

  • Modify: docs/user/safe-stop-and-recovery.md

  • Create: docs/testing/2026-10-30-reliable-supervision.md

  • Test: tests/ui/test_ui_execution_feedback.py

  • Add UI assertions for typed missing-result, forced-stop, and resource-pending messages.

  • Run the complete current-version UI/V1.1 suite, final affected-path regression, and required release safety subset. The extra full historical execution was stopped and is not reported as passed; see the testing report for exact scope.

  • Document evidence locations, recovery order, and the no-replay rule.

  • Record unperformed real CAD/frozen EXE validation and incomplete historical execution explicitly; no skipped or incomplete run is reported as passed.