feat(dsh): add CAD verification recovery diff and issue broker
This commit is contained in:
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.
|
||||
@@ -0,0 +1,30 @@
|
||||
# DSH 生产闭环增强设计
|
||||
|
||||
## 目标
|
||||
|
||||
把 DSH 从“能监管受控执行”推进到“能解释真实 CAD 验证状态、按错误类别安全处理、在恢复前展示差异、并通过生产工单中转提交证据”。
|
||||
|
||||
## 四个阶段
|
||||
|
||||
### 1. CAD 验证适配器
|
||||
|
||||
`dsh/cad_verification.py` 封装现有 TaskCenterService、私有桌面 CAD 身份和前后探针。适配器只返回工程身份、探针基线、读回状态和证据引用,不接受模型传入的进程、路径或 COM 参数。预检只读;真实执行继续由现有原生确认和私有 CAD 会话负责。
|
||||
|
||||
### 2. 错误分类与受控重试
|
||||
|
||||
`dsh/failure_policy.py` 将错误归类为 `transient`、`deterministic`、`uncertain`、`paused` 或 `observe`,返回重试理由、等待时间和最大次数。自动介入只能对明确的 transient 且原执行已授权、无不确定证据的场景执行一次;deterministic 进入人工修正,uncertain 禁止重放。所有判定写入决策记录。
|
||||
|
||||
### 3. 恢复差异对比
|
||||
|
||||
`dsh/resume_diff.py` 对原始冻结范围、当前任务计划、队列检查点和已有证据生成有界差异。恢复确认窗口显示已完成、待执行、计划哈希、工程文件身份和阻断原因;差异存在时不得自动恢复。
|
||||
|
||||
### 4. 生产工单中转
|
||||
|
||||
`dsh/issue_transport.py` 的 broker 模式扩展为可部署的固定目标中转协议:服务端校验安装实例签名、仓库和事件幂等键,签发短期 issue-only token;客户端不缓存 token。新增 stdlib broker 参考服务和协议测试,生产部署仍需由运维配置服务端 secret 与 Git 凭据。
|
||||
|
||||
## 约束
|
||||
|
||||
- 模型不能直接获得 CAD 进程、COM、文件写入或任意工单 URL 权限。
|
||||
- 错误分类不能把“模型建议”当成可重试授权。
|
||||
- 恢复差异只读,差异未解决不得扩大执行范围。
|
||||
- broker 只允许固定服务器、固定仓库、固定事件标记和幂等写入。
|
||||
Reference in new issue
Block a user