feat: add DSH AI supervision core
This commit is contained in:
1 parent
12895e9868
commit
bf14b20a38
13 files changed
+382
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# DSH AI 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:** Add a tool-first AI supervision layer with deterministic auto-remediation and optional human chat to the task center.
|
||||
|
||||
**Architecture:** Keep all mutation in the existing service. Add small Python modules for snapshots, rules, action validation, and an OpenAI-compatible client; connect them to a Qt dialog and the existing error path.
|
||||
|
||||
**Tech Stack:** Python 3.12, dataclasses, urllib, PySide6, pytest.
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-10-30-dsh-ai-supervision-design.md`
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Model output is advisory JSON and never execution evidence.
|
||||
- Only fixed allowlisted actions may reach the service.
|
||||
- Missing model configuration must not disable deterministic supervision.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: DSH core contracts
|
||||
|
||||
**Files:** Create `src/dx_productivity/dsh/__init__.py`, `snapshot.py`, `rules.py`, `actions.py`, `client.py`, `supervisor.py`; Test `tests/dsh/test_core.py`.
|
||||
|
||||
- [ ] Define immutable `TaskSnapshot`, `Issue`, `ActionProposal`, and `ChatReply` records.
|
||||
- [ ] Implement redaction and issue classification with stable JSON-safe dictionaries.
|
||||
- [ ] Implement allowlisted action validation and idempotency keys.
|
||||
- [ ] Implement an OpenAI-compatible HTTP client with strict JSON parsing and a disabled configuration path.
|
||||
- [ ] Implement supervisor event handling that invokes only injected handlers.
|
||||
- [ ] Add tests for redaction, classification, malformed JSON, unknown actions, and retry idempotency.
|
||||
|
||||
### Task 2: Service adapter and automatic remediation
|
||||
|
||||
**Files:** Create `src/dx_productivity/dsh/service_adapter.py`; Modify `src/dx_productivity/trial_task_center/ui/main_window.py`; Test `tests/dsh/test_service_adapter.py`.
|
||||
|
||||
- [ ] Adapt `prepare_failed_quick_run`, `pause_task`, and read-only feedback behind fixed action names.
|
||||
- [ ] Connect UI error reporting to supervisor observation without changing existing error messages.
|
||||
- [ ] Auto-run only retryable failures and record outcomes.
|
||||
- [ ] Add tests using a fake service and verify duplicate events do not repeat actions.
|
||||
|
||||
### Task 3: Human assistant panel
|
||||
|
||||
**Files:** Create `src/dx_productivity/trial_task_center/ui/dsh_panel.py`; Modify `main_window.py`; Test `tests/ui/test_dsh_panel.py`.
|
||||
|
||||
- [ ] Add a compact Qt dialog with issue summary, action cards, chat input, send/stop state, and local audit list.
|
||||
- [ ] Display an explicit unconfigured-model state and keep local actions usable.
|
||||
- [ ] Require confirmation for proposals marked `requires_confirmation`.
|
||||
- [ ] Cover offscreen rendering and send/response state with fake client.
|
||||
|
||||
### Task 4: Documentation and regression verification
|
||||
|
||||
- [ ] Document configuration and limits in `docs/user/dsh-ai-supervision.md`.
|
||||
- [ ] Run DSH tests and the existing UI/service regression suites.
|
||||
- [ ] Run `python -m compileall src` and record results.
|
||||
@@ -0,0 +1,24 @@
|
||||
# DSH AI 监管与修复设计
|
||||
|
||||
## 目标
|
||||
|
||||
在 `codex/dsh` 分支为 DxDesigner 器件替换任务中心增加一个工具优先的 AI 监管层:异常时先用本地规则自动处理,复杂情况可人工对话;模型只能给出结构化提案,不能直接操作工程或系统。
|
||||
|
||||
## 架构
|
||||
|
||||
`dsh.supervisor` 接收任务事件并生成脱敏快照,`dsh.rules` 负责确定性分类和自动动作白名单,`dsh.client` 负责可选的 DeepSeek/OpenAI 兼容 JSON 对话。动作由 `dsh.actions` 校验后委托现有 `TrialTaskCenterService`,UI 仅展示状态、对话和需要确认的动作卡。
|
||||
|
||||
## 安全边界
|
||||
|
||||
- 自动处理仅允许明确失败重试、只读刷新和安全暂停请求。
|
||||
- 规则修改、工程写入、恢复不确定状态必须人工确认。
|
||||
- 模型输入仅为任务状态、进度、错误摘要和规则元数据;不发送路径内容、密钥或工程文件。
|
||||
- 模型输出必须是 JSON;未知字段、未知动作、超长文本和无效参数一律拒绝。
|
||||
- 未配置模型时本地监管照常工作。
|
||||
|
||||
## 第一版验收
|
||||
|
||||
- 可构造脱敏快照并识别 `failed`、`timeout`、`uncertain`、`paused`。
|
||||
- 明确失败可生成幂等 `retry_failed` 动作并调用现有服务。
|
||||
- UI 可打开助手面板,发送问题并显示模型回复或未配置提示。
|
||||
- 所有动作和结果进入监管内存日志,且不替代现有执行证据。
|
||||
@@ -0,0 +1,5 @@
|
||||
# DSH AI 监管助手
|
||||
|
||||
DSH 是任务中心内的工具型监管入口。它先使用本地规则识别失败、超时和不确定状态;明确失败可生成一次性的重试动作。模型只负责解释和提出结构化建议,不能直接调用 CAD、Shell、文件系统或任意网络工具。
|
||||
|
||||
打开任务中心的“DSH AI 监管”后,可以查看当前任务状态并进行人工对话。未配置 DeepSeek/OpenAI 兼容接口时,对话会明确提示,但本地监管和固定动作仍然可用。工程写入、规则修改和不确定状态恢复始终需要人工确认。
|
||||
Reference in new issue
Block a user