feat(dsh): add CAD verification recovery diff and issue broker

This commit is contained in:
阿白叔 committed 2026-10-31 10:17:26 +08:00
1 parent eee4e6bde9
commit 27334fef81
23 files changed
+553 -12

No files matched your search

@@ -0,0 +1,102 @@
# DSH 生产闭环增强实施计划
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
**Goal:** Add real CAD verification visibility, safe failure classification, resume diffs, and a deployable fixed-target issue broker contract.
**Architecture:** Reuse the existing TaskCenterService and private CAD identity as the only execution authority. Add bounded Qt-free analyzers, then expose their read-only results through existing preflight, incident, resume confirmation, health, and issue transport paths.
**Tech Stack:** Python 3.12, PySide6, stdlib HTTP server/client, existing SQLite/JSON evidence stores, pytest, Node and Qt/CDP acceptance.
**Spec:** `docs/superpowers/specs/2026-10-31-dsh-production-chain.md`
## Global Constraints
- Work only in `.worktrees/codex-dsh` on branch `codex/dsh`.
- Never print, stage, or commit provider keys, Git tokens, broker secrets, or ignored bootstrap files.
- Keep native confirmation, safe pause, original queue identity, and automatic snapshot-only admission unchanged.
- Controlled fixtures must not start real CAD or write user projects.
---
### Task 1: Real CAD verification adapter
**Files:**
- Create: `src/dx_productivity/dsh/cad_verification.py`
- Create: `tests/dsh/test_cad_verification.py`
- Modify: `src/dx_productivity/dsh/task_lifecycle.py`
**Interfaces:**
- `CadVerificationAdapter(service).preflight(task_ids) -> dict` returns `mode`, `status`, `projects`, `blockers`, and `evidence_refs`.
- `CadVerificationAdapter(service).after_run(task_ids) -> dict` returns readback status and actual progress counters.
- [x] Write tests for ready fixture, missing probe, identity mismatch, uncertain result and exact counter preservation.
- [x] Run the focused tests and observe the missing-module failure.
- [x] Implement read-only checks using `task_context`, `expected_probe_path`, project file identity and existing evidence; never invent component counts.
- [x] Include adapter result in DSH preflight and execution impact context.
- [x] Run focused adapter and lifecycle tests.
### Task 2: Failure classification and safe retry policy
**Files:**
- Create: `src/dx_productivity/dsh/failure_policy.py`
- Create: `tests/dsh/test_failure_policy.py`
- Modify: `src/dx_productivity/dsh/incidents.py`
- Modify: `src/dx_productivity/dsh/rules.py`
**Interfaces:**
- `classify_failure(issue_code, status, *, interrupted=False, authorized=False) -> dict` returns `category`, `retry_allowed`, `reason`, `backoff_seconds`, and `max_attempts`.
- [x] Write tests for transient, deterministic, uncertain, paused and unknown errors.
- [x] Run focused tests and observe expected failure.
- [x] Implement conservative classification; only transient authorized runs with clean evidence can retry once.
- [x] Replace raw `RETRYABLE_CODES` checks in automatic incident flow with the policy result and append it to decision gates.
- [x] Run incident, decision-log and policy tests.
### Task 3: Resume difference report
**Files:**
- Create: `src/dx_productivity/dsh/resume_diff.py`
- Create: `tests/dsh/test_resume_diff.py`
- Modify: `src/dx_productivity/dsh/run_journal.py`
- Modify: `src/dx_productivity/trial_task_center/ui/dsh_task_lifecycle.py`
- Modify: `integration/dsh/task-plugin/model_results.mjs`
**Interfaces:**
- `resume_diff(service, inspected_run) -> dict` returns `safe`, `changed`, `completed`, `remaining`, `plan_changes`, `evidence_changes`, and bounded `blockers`.
- [x] Write tests for unchanged scope, completed items, plan change, missing checkpoint and uncertain evidence.
- [x] Run focused tests and observe expected failure.
- [x] Implement deterministic diff from saved hashes, current plan hashes, queue entries and task evidence.
- [x] Add diff to resume inspection and native confirmation text; block automatic resume when `safe` is false.
- [x] Project bounded diff fields to model results and run lifecycle/UI tests.
### Task 4: Broker reference service and client hardening
**Files:**
- Create: `tools/dsh_issue_broker.py`
- Create: `src/dx_productivity/dsh/issue_broker.py`
- Create: `tests/dsh/test_issue_broker.py`
- Modify: `src/dx_productivity/dsh/issue_transport.py`
- Modify: `docs/user/dsh-ai-supervision.md`
**Interfaces:**
- `IssueBrokerConfig.from_environment()`, `IssueBroker.exchange(payload) -> dict`, and `IssueTransport.credentials(...)` with `instance_proof`, `idempotency_key`, `expires_in`.
- Reference HTTP endpoints: `GET /healthz`, `POST /v1/issue-token`.
- [x] Write tests for fixed target, HMAC instance proof, idempotency, short expiry, invalid scope, and no secret in response logs.
- [x] Run focused tests and observe expected failure.
- [x] Implement the broker with stdlib `ThreadingHTTPServer`, fixed target configuration, environment-only secret/token, bounded requests and no redirects.
- [x] Require broker exchange metadata in the client and reject responses with missing expiry or wrong target.
- [x] Document deployment variables and explicitly label the local server as a reference implementation.
- [x] Run broker, transport, ticket, and health tests.
### Task 5: Full verification and commit
**Files:**
- Modify: `docs/testing/2026-10-31-dsh-production-chain.md`
- [x] Run focused and relevant regression tests, Node checks, credential scan and `git diff --check`.
- [x] Run two-process Qt/CDP acceptance with the adapter enabled in controlled mode.
- [x] Record exact artifacts and limits; no real CAD or remote issue creation claims.
- [x] Commit only intended files on `codex/dsh` and verify clean status.