docs(assistant): record DSH workspace verification and native UI reuse

This commit is contained in:
abaishu0730 committed 2026-10-27 17:30:55 +08:00
1 parent 12820f0117
commit 59e0a44bcc
6 files changed
+207 -4

No files matched your search

@@ -0,0 +1,70 @@
# DSH 诊断工作区验证记录
日期:2026-10-27(Asia/Shanghai)。用户批准[设计](superpowers/specs/2026-10-27-dsh-diagnostic-workspace-design.md)后在 `dsh` 分支实施,[实施计划](superpowers/plans/2026-10-27-dsh-diagnostic-workspace.md)记录任务与边界。
## 交付
- 三栏工作区、固定输入区、个人会话标题搜索、手机抽屉、按轮次保留的诊断依据,以及概况/证据/操作/记录侧栏。
- 自然语言与 `/help`、`/status`、`/bpm`、`/storage`、`/archive`;本地命令不调用模型或外部恢复操作,诊断目标由服务器复核。
- 官方 DSH headless 阶段适配、加密持久事件、状态一致事务、请求去重、SSE 补读及轮询回退;最后事件的权威数据读取成功后才推进游标。
- 串行事件交付与权威读取、断线恢复探测的单一轮询所有权、响应头超时、离页释放,以及权限变化后清空整个旧工作区。
- 待确认操作只在点击后执行,失败/受阻/需选择/待审查/待核验分别显示;旧归档的权限不受最近记录展示条数影响,选定旧目标的脱敏元数据会进入实际诊断快照。
- 保留连续对话、取消、个人历史、样本/字段能力及管理员隔离修复;修复入口迁到右侧记录面板。
界面:[桌面截图](images/user-guide/assistant.png)、[手机截图](images/user-guide/assistant-mobile.png)。已检查 1600×900、1366×768、1024×768、390×844,输入区可达、无横向溢出。
## DSH 复用证据
固定官方版本为 `0.2.1-rc.2`。服务端继续复用官方 Session/Projection/Agent/Headless 最小 profile,新增白名单阶段适配,未启用原生 Shell、文件、MCP 或插件工具。
浏览器直接提取上游 `clampWidth`、`computeColumns`、`groupOptions`,适配固定目录的命令解析和候选筛选。实际布局和命令菜单调用这些函数;未引入 React/Cordis 前端构建链或第二套 DSH Web 账号。来源及 MIT 声明见[复用清单](../licenses/DSH-native-NOTICES.md)和[许可](../licenses/DeepSeek-Harness-MIT.txt)。Markdown 固定为 `marked 18.1.2`,许可同仓保存;原始 HTML 转义、图片不加载、链接协议过滤已有浏览器验证。
首版推送真实阶段与受控操作进展,回答通过完整 JSON 校验后展示,不逐字输出。thinking、原始 stderr、密钥和原始运行路径不会进入 UI 事件。
## 已通过的验证
| 检查 | 结果 | 本机收据 |
|---|---|---|
| 锁定依赖重新安装 `npm ci` | 安全审计 0 项漏洞;安装正常退出 | `output/verification/dsh-workspace/final-npm-ci.log` |
| 最终隔离环境 `npm test` | **334/334 通过,0 失败,0 跳过** | `isolated-business.log` |
| 工作区 UI、HTTP、事件客户端专项 | 21/21 通过 | `final-workspace-focused.log` |
| 事件持久化与归档权限/目标专项 | 15/15 通过 | `final-archive-contract.log` |
| 权限变化清空工作区专项 | 1/1 通过;也纳入最终业务回归 | `tests/assistant/diagnostic-workspace-ui.test.cjs` |
| 固定官方 DSH + 本地假 Messages 接口 | 已通过;包含工具为空、阶段、输出校验、取消、Windows 子进程树清理 | 事件内核报告与最终业务回归 |
| 分辨率、Markdown、命令无隐藏副作用、会话草稿/DOM、断线/撤权 | 已通过 | UI 与事件客户端专项 |
表中缩写日志均位于 `output/verification/dsh-workspace/`。这些本机收据保留在 Git 忽略目录,源码、测试、许可及本记录进入分支。
最后一次业务回归为已提交应用代码 `12820f0` 的隔离验证。此前同一流程曾有一次 330/330 通过;随后增加目标权限、Markdown、撤权和搜索回归,最终计数以 334/334 为准。
## 全量检查的实际范围与限制
执行了 `npm run test:full`。首段使用现有默认环境和并发 2,已完成 `tests/order-rules/web.test.cjs` 之前的 181 个测试文件。此段既有旧页面断言失败,也反复出现 Windows 凭据目录权限设置的 `ETIMEDOUT`,原始日志保留为 `final-full.log`。
为避免继续使用历史凭据目录,记录当时仍在运行的测试文件,结束本次测试进程树,以新的临时 `LOCALAPPDATA` 和并发 1 接续最后 33 个文件。通过临时 junction 引用现有 DSH 运行包,临时凭据目录与运行服务目录分离。
全部 **214 个测试文件均已执行覆盖**;首段活动文件在续跑时从文件开头重新执行。续跑结果为 **134 项,133 通过、1 失败、0 跳过**,见 `full-resumed.log`。唯一失败为 `workbench.test.cjs` 的 `publication overlap uses paired rows and permits disjoint pairs sharing both columns`,已在改动前 `b2498ba` 副本复现,见 `baseline-publication-overlap.log`。
分段检查没有产生一个可称为“全量通过”的合并结果,首段也没有完整结束汇总,因此不把两段通过数直接相加为整套通过数。首段当时报告的请求去重夹具使用了不存在的 BPM 来源,新增服务端目标复核后已补充合法测试来源,并经 15/15 专项及最终 334/334 回归验证。
## 基线对照
基线取 `b2498ba`(应用代码仍为本次 DSH 改动之前的状态),通过 Git archive 放入独立临时目录;没有切换当前分支或覆盖用户文件。
| 对照检查 | 基线结果 | 结论/收据 |
|---|---|---|
| 密码窗口清理、记录关闭、旧采集契约、首页刷新及部分保存流程 | 8 项中 7 失败 | 相应失败在基线复现;`baseline-known-failures.log` |
| 两个旧 Web 闭环文件 | 30 项中 9 失败 | 与首段对应;`baseline-legacy-web-closure.log` |
| BPM 远程登录画面 | 1 失败 | 基线同样超时;`baseline-bpm-ui.log` |
| 不确定结果、惠州模板和旧订单映射页面的选定检查 | 8 项中 7 失败 | 页面/契约失败在基线复现;`baseline-additional-ui.log` |
| SSO 401、加密投递与旧 Excel 校验 | 默认环境 3 项中 2 失败 | 其中凭据目录超时也在基线出现;`baseline-additional.log` |
| 同三项在当前分支的隔离环境复验 | SSO 401、加密投递通过;旧 Excel 校验失败 | 旧 Excel 校验也在基线失败;`current-additional-isolated.log` |
| 分类规则交叉匹配 | 1 失败 | 续跑唯一失败在基线复现;`baseline-publication-overlap.log` |
这些对照不能证明首段每一项失败均为旧问题;完整测试集仍有未解决的旧流程/断言及环境限制。本次未修改无关的分类规则、字段编辑或凭据保护实现来消除这些失败。
## 审查及交付边界
事件内核与整支分支均经独立审查,已处理原生终态后非法活动、需人工选择结果、游标过早提交、旧证据残留、重复轮询、响应头超时、旧目标残留、旧归档授权受截断影响及权限变化后的数据清理;最终审查无未解决的 P1/P2。
模型验证只使用官方运行包和本机假模型接口,未进行真实模型/公司业务的端到端验收。本轮未部署、更新或重启当前运行服务;运行配置是否启用仍由原配置控制。现有三个未跟踪业务设计文档保留,未纳入本次提交。
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 59 KiB

@@ -0,0 +1,125 @@
# DSH Diagnostic Workspace Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [x]`) syntax for tracking.
**Goal:** 在现有工作台提供尽可能复用 DSH 的三栏运行诊断体验、真实阶段推送与受控诊断命令。
**Architecture:** 官方 DSH 0.2.1-rc.2 headless 继续负责模型运行,应用适配原生阶段事件。会话状态和加密事件同库事务提交,SSE 与轮询读取同一递增序列;原生布局/命令纯逻辑优先提取复用,工作台负责身份、权限、业务证据和确认执行。
**Tech Stack:** Node.js >=22.13、CommonJS、SQLite/AES-GCM、原生浏览器 JS、Tabler、Playwright、官方固定 DSH。
**Spec:** [approved design](../specs/2026-10-27-dsh-diagnostic-workspace-design.md),用户于 2026-10-27 批准执行并强调尽可能复用 DSH/做适配。
## Global Constraints
- 原地使用用户明确创建的 `dsh` 分支;不切换主分支,不提交原有三个未跟踪业务文档。
- 继续使用官方 DSH 0.2.1-rc.2 最小 profile;不为模仿原生界面挂载文件/Shell/MCP/插件/自主任务工具。
- 保留个人会话归属、角色、操作审计、100 轮限制、每日额度、全局最多 2 个模型调用。
- 首版“流式”指真实阶段/受控操作进展推送;不包含逐 token 回答。
- `thinking`、原始 stderr、运行环境、密钥、原始 cwd 不进入 UI 事件;回答与卡片只在完整校验后发布。
- 不改变业务发送资格、归档前置关系、收件人、业务规则或 SMTP unknown 的人工核验边界。
- 不启用真实模型、不调用真实恢复操作、不重启/部署正在运行的服务。
- 无新增前端构建链;上游源码提取须固定版本、文件和 MIT 许可。
## Task 1: Durable events and official headless adaptation
**Files:** create `src/modules/assistant/conversation-events.cjs`, `src/modules/assistant/dsh-events.cjs`, `tests/assistant/workspace-events.test.cjs`; modify assistant `store.cjs`, `service.cjs`, `conversation-history.cjs`, `dsh-runtime.cjs`.
**Interfaces:**
- `store.events(id, owner, {after=0,limit=100}) -> {events,nextCursor,hasMore}`; events `{schemaVersion:1,conversationId,seq,turnId,actionId?,kind,at,data}`.
- `store.eventCursor(id,owner) -> number`; `store.stage(turnId,kind,data={})`; conversation includes `eventCursor`.
- `service.send(id,principal,text,{diagnostic,requestId,repair}={})` remains synchronous; stores request identity before a model task is launched. Same request and payload reuses turn, conflict rejects 409.
- `runtime.chat({...existing,onEvent})` sends sanitized native lifecycle callbacks synchronously; only statuses exposed, full reply returned as before.
- Persist `turn.diagnosticSnapshot` with already sanitized context actually used; stored encrypted. `cancelRequested` is transient until exit confirmation; unknown stop/result remains needs_review.
- [x] Write behavior tests before implementation: create store, begin/update turn, verify ordered events and encrypted disk, reject other owner and ahead/negative cursors; restart produces interruption events; request dedup uses one model call and conflicts on changed payload.
```js
const c=store.create('alice');
const t=store.beginTurn(c.id,'alice','diagnose');
const before=store.eventCursor(c.id,'alice');
store.updateTurn(t.id,'success',{reply:'checked'});
assert.ok(store.events(c.id,'alice',{after:before}).events.length>0);
assert.throws(()=>store.events(c.id,'bob',{}),e=>e.status===404);
```
- [x] Run `node --test tests/assistant/workspace-events.test.cjs` and capture expected missing event interface failure.
- [x] Add transactional encrypted event table; reuse existing store transactions (nested writes run within existing transaction), bounded 128 events per turn with reserved terminal slots; stage only safe schema fields. Use persisted states as authority, not event text.
```js
// All state changes and UI events share the assistant database transaction.
store.transaction(()=>{ /* update existing turn and append validated event */ });
// Native NDJSON status arrives before process completion.
onEvent?.({kind:'model',data:{phase:'step_start'}});
```
- [x] Add incremental UTF-8 NDJSON decoder and native event validation, retaining existing final parsing/timeout/tree cleanup; reject tools/errors/unknown events, immediately discard thinking and never publish text JSON fragments.
- [x] Integrate stage, dedup, stored evidence, cancellation, action progress/terminal and recover events without changing authorization, final parsing or action execution semantics.
- [x] Run new tests and `node --test --test-concurrency=1 tests/assistant/assistant.test.cjs tests/assistant/dsh-runtime.test.cjs tests/assistant/controlled-operations.test.cjs tests/assistant/conversation-lifecycle.test.cjs` and commit only owned files.
## Task 2: Authenticated diagnostics and resilient event transport
**Files:** create assistant `diagnostic-context.cjs`, `event-stream.cjs`, `tests/assistant/workspace-http.test.cjs`; modify `policy.cjs`, `api.cjs`, `conversation-history.cjs`, `src/app/dashboard.cjs`, `src/app/application.cjs`.
**Interfaces:** consumes Task 1 events/store methods; produces `/assistant/context`, `/conversations/:id/events?after=N`, `/stream?after=N`; `assistantStreams.close()` drains streams. Add `query` search and `{diagnostic,requestId}` request validation.
- [x] Write HTTP tests for owner-only event replay, heartbeat, Last-Event-ID, future/invalid cursor rejection, cookie invalidation and clean close. Context tests prove reads have no external side effects and diagnostic IDs are reauthorized server-side.
```js
assert.equal((await call('/api/assistant/conversations/'+id+'/events?after=-1',undefined,cookie)).status,400);
assert.equal((await call('/api/assistant/context',undefined,cookie)).status,200);
assert.equal(modelCalls,0);
```
- [x] Run `node --test tests/assistant/workspace-http.test.cjs`, observe expected route failures.
- [x] Project context from existing snapshot + source authorization; only present identifiers already readable on business pages. Validate exact `/help /status /bpm /storage /archive` command catalog, string targets and unknown fields; prohibit automatic command-to-write dispatch.
- [x] Add safe cursor parsing; SSE reads durable log in ascending batches so replay/live transition cannot miss events. Keep last cursor only after frame write, bound buffer 256KiB, each user max2/global30 streams, 15s heartbeat+reauth. End streams before `server.close` and databases. No timer or listener leaks on disconnect.
```js
response.write('id: '+event.seq+'\nevent: assistant_event\ndata: '+JSON.stringify(event)+'\n\n');
// Poll and SSE use exactly store.events and never call service.send/executeAction.
```
- [x] Extend title search: active limit50, archived recent2000, chunk100 with event-loop yields, encrypted titles only and explicit search range/truncation.
- [x] Run HTTP tests, assistant legacy HTTP tests and shutdown tests; commit only task files.
## Task 3: DSH native three-column workspace and commands
**Files:** create `web/modules/assistant/{dsh-native,layout,conversation,commands,context-panel,events-client}.js`, `workspace.css`, license/source notice and UI behavior tests; modify assistant `view.js`, `operations.js`, `web/index.html`, `src/app/assets.cjs`, `web/app.js` as needed for disposal.
**Interfaces:** browser globals `AssistantNative`, `AssistantLayout`, `AssistantConversation`, `AssistantCommands`, `AssistantContextPanel`, `AssistantEvents`; modules consume configured `{api,esc,formatDate,user}` and return explicit cleanup functions. Keep `window.AssistantViews.configure/render/settings`.
- [x] Add UI tests that fail current page: at1366×768 input visible; `/help` and `/status` cause zero model calls; unknown commands stay in draft; narrow panes mutually exclusive; phase updates retain reply DOM/selection; cleanup closes SSE on navigation; repair result blocked/needs_review uses actual label.
- [x] Run `node --test tests/assistant/diagnostic-workspace-ui.test.cjs`, record missing layout/command failures.
- [x] Extract pure native `clampWidth/computeColumns` and command resolution/search functions from installed fixed DSH bundle; adapt only dependency/exports wrappers. Retain license and exact source mapping. Use these helpers in actual layout and menu; no unused vendor assets.
```js
const columns=AssistantNative.computeColumns(width,sidebarOpen?264:0,rightOpen?320:0,width<880?0:56);
// Native command resolution targets only the project's fixed catalog.
```
- [x] Replace stacked cards with compact header/left catalog/middle transcript+composer/right tabs; move audit/admin advanced form into right side. Keep old action IDs and API permissions. Render authoritative action result distinctions and target/impact before confirm.
- [x] Update keyed transcript nodes instead of replacing messages.innerHTML; safe Markdown headings/lists/tables/code and links with escaped raw HTML/no remote images. Preserve per-conversation in-memory draft/scroll/folds; text copied via explicit button.
- [x] Add typed target selections, exact commands, keyboard/IME, whitespace/length validation; one requestId per send attempt until server outcome resolved. Retrying diagnosis creates new round, never executes actions.
- [x] Add authenticated fetch SSE client with1/2/4/8/15s backoff, fallback after3 stream failures to3s event polling, SSE probe every60s, abort on leave/logout, no automatic message POST retry. Handle new data without stealing reading scroll.
- [x] Run new and legacy UI tests; four viewport screenshots inspected; commit owned files.
## Task 4: Integration review and validation
**Files:** `docs/user-guide.md`, design status, plan checkboxes, `docs/dsh-workspace-verification-2026-10-27.md`; fixes scoped to findings.
- [x] Independently review state transitions, authorization, external side effects, schema compatibility, NDJSON limits, SSE replay/close and native source usage. Fix important issues with covering tests.
- [x] Execute `npm ci`, assistant suite, fresh `npm test`, then `npm run test:full` because shutdown paths change. Save isolated receipts under ignored output and distinguish failures reproducible at baseline from regressions; do not present a filtered run as full pass.
- [x] Inspect screenshots at1600×900,1366×768,1024×768,390×844; validate real fixed official DSH using local fake Messages provider only; no real model enabled or service restart.
- [x] Update guide and verification with exact commands/counts, source reuse evidence and limitations. Mark tasks according to evidence, commit scoped tracked files, leave user untracked documents intact.
## Execution rulings
- User already authorized implementation; execute inline with specialist implementation/review, without new preference/approval prompts.
- Existing `dsh` branch is the user-selected workspace; no additional worktree is required for this in-place task. Tests use temporary state directories, not running business state.
- Backend Task1 and root's frontend/transport work own separate files until integration; only one implementation subagent is active at a time. Code reviews are read-only.
- Fresh baseline receipts are kept separately; only test failures with evidence of preexistence may be labeled pre-existing.
## Execution outcome
2026-10-27 已实施。最终隔离业务回归334/334通过,独立审查无未解决P1/P2;全量按181+33个文件分段覆盖,旧流程/环境失败如实保留。详细结果见[验证记录](../../dsh-workspace-verification-2026-10-27.md)。本轮未部署运行服务。
@@ -4,7 +4,7 @@
分支:`dsh`;调研基线:`d744c363654bfaacf217f5b0f85a10fea0e45abb`
状态:方向与主要交互已确认;本文汇总设计,待用户整体评审。本文不是编码或部署授权。
状态:用户于 2026-10-27 批准按本文执行,并强调尽可能复用 DSH 或做适配以节省时间。实施仍不包含运行服务部署。
## 1. 已确认的方向
@@ -243,8 +243,8 @@ Open WebUI 已是本项目早期会话布局的参照,见[原助手设计](202
## 9. 评审与后续边界
本轮只产出设计文档。主要待整体评审的是:三栏首屏的具体布局、原生组件的适配策略、第一版阶段推送而非逐字回答、固定命令行为、恢复/待核验及上述四批交付顺序。
用户已批准三栏首屏、原生组件适配、第一版阶段推送而非逐字回答、固定命令、恢复/待核验及四批交付顺序。
本文批准后,使用 writing-plans 编写 `docs/superpowers/plans/2026-10-27-dsh-diagnostic-workspace.md`,再执行开发。当前不生成名为“已批准”的实施计划,不修改应用代码、配置、运行态或真实业务数据。
实施任务与进度见[实施计划](../plans/2026-10-27-dsh-diagnostic-workspace.md)。应用代码可按计划修改;配置启用、运行服务更新和真实业务操作不随界面改造自动执行。
关联依据:[DSH 受控能力设计](2026-10-27-mail-dsh-controlled-optimization-design.md)、[原助手设计](2026-10-17-zcode-chat-design.md)、[当前设计要求](../../design-requirements.md)、[用户指南](../../user-guide.md)。
+9 -1
View File
@@ -61,7 +61,15 @@
![DSH 助手](images/user-guide/assistant.png)
可建立和继续对话、查看会话历史,并在助手已配置且运行时查询系统状态、分析运行异常或提出受控操作。允许的操作由管理员在助手设置中限定;执行前会显示操作内容并要求确认,操作和结果写入审计记录。助手不是 BPM 自动办理入口,也不能替代业务核验。不要向对话输入密码、Cookie、完整业务表单或不必要的客户信息。
助手采用 DSH 原生交互适配的三栏工作区:左侧搜索/切换个人会话,中间阅读回答和本轮过程,右侧查看概况、证据、操作及记录。输入区固定在中栏底部;手机通过“会话列表”和“上下文”按钮打开侧栏。归档保留历史,继续新对话带入最近三轮上下文。归档标题搜索覆盖最近 2000 个,超出时页面明确标注范围。
可直接描述连接、扫描或归档异常,也可输入 `/` 打开固定命令菜单。`/help` 展示帮助,`/status` 只刷新本机授权概况;`/bpm`、`/storage`、`/archive` 选择可见目标后填入诊断草稿,发送才调用模型。概况刷新不会自动检查外部连接,未知命令不会作为提示词发送。未配置模型时仍可查看授权概况。
过程按真实阶段推送,断线后补读,必要时回退轮询;首版回答在完整校验后显示,不逐字输出,也不展示模型内部思考。概况是最近观测,证据页是该轮实际使用的快照,两者时间和范围可能不同。停止只针对模型回复,确认进程退出前显示“正在停止”;操作中断或结果不明显示“待核验”。
点击回答下方“查看操作”可审查目标、影响和操作编号,再点执行。允许的动作仍由管理员及工作台权限限定;断线、刷新、重新诊断都不会自动执行或重放旧操作。管理员代码修复入口在右栏“记录 → 提出代码修复”,先展示修改前后,测试通过后仍待审查。操作与结果保留审计。
助手不是 BPM 自动办理入口,也不能替代业务核验。不要向对话输入密码、Cookie、完整业务表单或不必要的客户信息。
### 存储服务器