@alpacachen/dsh-kanban 1.11.3 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,87 @@
1
+ # Workflow guide
2
+
3
+ [中文](workflow-guide.md) · [Back to README](../README.md)
4
+
5
+ Open **Kanban · Workflow** in the sidebar. Switch to **Workflow** beside the workspace name. The home table groups tasks under each workflow; collapse a workflow to hide its tasks and inline task composer.
6
+
7
+ ## Create and edit a workflow
8
+
9
+ Choose **Create workflow in chat** and describe the goal, expected input, AI stages, deliverables and human review points. The Agent saves the definition with `workflow_create`, or reads its current revision with `workflow_list` before using `workflow_update`.
10
+
11
+ New AI stages inherit the model and reasoning effort used in the authoring conversation. The Agent tools do not accept model parameters. Later, click an AI stage in the workflow detail to edit its instructions and select a model using DSH's ModelSelect. Model selection saves immediately; text changes use Save or ⌘/Ctrl+Enter. Structural changes, including adding, deleting and reordering stages, remain in Agent chat. Human review stages have no model setting.
12
+
13
+ There is no draft, publish or enable step. Saving makes the workflow available to new tasks. Existing tasks retain their original definition and models. AI edits preserve model choices for unchanged stage IDs; new stages inherit the editing conversation's model.
14
+
15
+ ## Run a task
16
+
17
+ On the home list, expand a workflow and choose **Create task**. Enter the task input and send, or use ⌘/Ctrl+Enter. The input also serves as the displayed task title; no separate name or task-level model choice is needed.
18
+
19
+ Each stage runs in the task's own output directory using the default DSH Agent preset, tools and authorization. The Agent also receives the original project's absolute path for reading materials or making requested project changes. Workflow adds no separate network, file or command permissions, model-turn or tool-call counts, stage-time budget, or output-token budget.
20
+
21
+ Stages in one task run sequentially. Workflow runs up to two AI stages at once across different project directories. Tasks in the same directory queue, and tasks waiting for human review do not occupy an execution slot. Tool concurrency, compaction and model-request retries follow DSH. A failed workflow stage does not automatically run again: inspect the cause, then retry the current stage when appropriate.
22
+
23
+ ## Follow the work
24
+
25
+ Task detail shows the stage diagram and deliverable files. The current stage stays highlighted; click a node to inspect its instructions, native DSH conversation, available reasoning text, tool calls, replies and saved reports in a centered DSH modal. Inspecting a stage does not rerun it. The modal stays on the selected stage as execution advances; close it or press Escape to return to the diagram. Closing does not cancel the task.
26
+
27
+ The canvas starts at 100% and centers the current stage. Drag or use a trackpad to pan, scroll or pinch to zoom, and choose **View full workflow** to fit the whole diagram. It does not add scrollbars or reset your view on every task update.
28
+
29
+ Workflow hides its reserved handoff block and generated orchestration input in the reading view. Old unfenced replies default to the cleaned report, with the original conversation available separately. Raw saved records and integrity hashes are unchanged.
30
+
31
+ ## Review and handle interruptions
32
+
33
+ A human stage pauses the task until you decide:
34
+
35
+ - **Approve and continue** accepts the reports bound to this review and advances the task.
36
+ - **Return for rework** requires feedback and returns to the configured earlier AI stage. Superseded reports remain in history.
37
+ - **Retry stage** reruns a stopped, failed current stage while retaining completed upstream stages.
38
+ - **Stop task** opens a small confirmation dialog and asks DSH to stop. It is also available in the running stage's header. “Terminating” means stop confirmation is still pending.
39
+
40
+ Completed review nodes retain the decision time and exactly the reports bound to that decision. Approval concerns saved stage reports, not an immutable version of the project directory. Returning or stopping does not undo file changes or external side effects. Static deliverables should describe their contents and generation time rather than carry a live “awaiting approval” label.
41
+
42
+ After DSH exits or the plugin reloads, interrupted execution remains in **Needs attention** and is not silently redispatched. Choose **Reconcile previous execution**, check that old commands and external operations have stopped, and confirm. Commands can survive a forced DSH exit on macOS; an empty job list in a new Host does not prove they stopped. Workflow also checks native session ownership, original input identity and associated jobs. A busy native session or job cannot be released by checking the confirmation box.
43
+
44
+ After reconciliation, a task already marked for termination becomes terminated; otherwise you decide whether to retry the current stage. Reconciliation sends no new message and does not cancel unrelated later chat. A disconnected page retains its last data, disables execution/review actions and reconnects automatically.
45
+
46
+ ## Stage handoffs
47
+
48
+ Stages use separate DSH sessions. Each receives its instructions, original task input, valid upstream handoff summaries, a report/file index and human feedback. They do not inherit every previous chat or report in full.
49
+
50
+ The final reply includes a reserved `workflow-handoff` code fence containing `<workflow-handoff>` JSON with `conclusions` (text and evidence references), `openIssues` and `nextActions`. The summary is generated in the same model execution. Important numbers, dates, IDs, uncertainties and evidence locations should remain explicit; full detail belongs in reports and files.
51
+
52
+ The scheduler preserves each valid upstream stage's own summary instead of repeatedly rewriting a cumulative summary. The index includes report paths, SHA-256 and file sizes. If a summary is absent or invalid, the next stage is instructed to read the full report; missing summaries alone do not fail a task. Superseded results are excluded from valid upstream context. A file's presence alone does not mean its conclusions are current.
53
+
54
+ ## Files and deletion
55
+
56
+ Each task owns `<project>/.dsh/workflow-artifacts/<taskId>/`. Its stages, retries and rework share the directory; different tasks use different directories. Files can be previewed in place without switching to a chat. Markdown and code use DSH rendering components; images, audio, video and PDFs use browser capabilities. Other formats can be inspected from the output directory. Preview file sizes follow DSH's file API limits.
57
+
58
+ Immutable stage replies are saved as DSH attachments and indexed in the Workflow database. Read-only `.workflow-results/<attemptId>.md` copies support on-demand report reading. They are execution history, excluded from the deletable deliverables list; missing or modified copies are repaired from verified attachments.
59
+
60
+ Deleting a deliverable requires confirmation and verifies that its version has not changed. It does not delete stage or review history. Deleting a stopped task also permanently removes its entire output directory, including stage reply copies; the dialog explains this. Removal is recorded in the database before files are cleaned up, and failed cleanup resumes after restart. Other task directories, project files and symlink targets are not deleted. Immutable DSH report attachments and audit records remain.
61
+
62
+ Workflow and task deletion are available in their detail views. Active or unconfirmed executions must be stopped first. Historic files outside task directories are not automatically moved or assigned to tasks.
63
+
64
+ ## Improve from history
65
+
66
+ Choose **Optimize from history** in workflow detail. This opens a new conversation with an analysis prompt; it does not execute a task. The Agent can use:
67
+
68
+ - `workflow_list` for the latest definition and revision.
69
+ - `workflow_list_tasks` for task summaries grouped by immutable workflow version.
70
+ - `workflow_get_task` for results, failures and review feedback; `includeOutputText: true` explicitly reads complete reports.
71
+ - `workflow_get_stage_trace` for the recorded conversation, tool arguments/results, timing, model steps, token/cache data, retries, compaction and authorization events, with pagination.
72
+
73
+ Tool durations are wall-clock intervals and can include waiting or authorization. Overlapping calls must not be summed as pure execution time. Missing metrics remain unknown. The main stage trace does not reveal a provider's internal queue or every child Agent's internal conversation. Reading history does not restore or rerun an Agent.
74
+
75
+ Saving an improvement affects only future tasks. Existing tasks keep their original version, stage IDs, files and records.
76
+
77
+ ## Data and backups
78
+
79
+ Back up the active Profile's `workflow-poc/workflow.sqlite`, the DSH attachment store, and each project's `.dsh/workflow-artifacts/` directories together. Stop the plugin or use a consistent SQLite backup; do not copy a live database while ignoring its WAL. The legacy `workflow-poc` storage name is retained to preserve existing records.
80
+
81
+ Kanban data is separate; see its [backup guide](guide.md#data-and-backups). Deleting a task's directory cannot be reversed through Workflow.
82
+
83
+ ## Compatibility and validation
84
+
85
+ This release targets **DSH 0.2.2-rc.3**. Host changes require a plugin reload; refreshing the frontend alone does not replace loaded backend modules. Models, tools and authorization remain DSH-owned.
86
+
87
+ Chinese and English interface text and dates follow DSH's language. User-authored names, prompts, feedback and saved outputs remain in their original language. See the [acceptance record](workflow-validation.md) for the checks performed and the macOS crash-recovery boundary; Windows and Linux native acceptance are not claimed.
@@ -0,0 +1,87 @@
1
+ # 工作流使用指南
2
+
3
+ 打开侧边栏「看板·工作流」,在顶部工作区右侧切换 **Kanban / Workflow**。Workflow 首页用两级列表展示流程及其任务:箭头展开或收起子任务与创建任务入口,点击流程名称打开流程详情,点击任务打开任务详情。
4
+
5
+ ## 创建和修改流程
6
+
7
+ 点击 **对话创建流程**,在新聊天中描述目标、输入、AI 步骤、交付结果和人工审核点。Agent 使用 `workflow_create` 创建完整流程,或先通过 `workflow_list` 读取当前 revision,再调用 `workflow_update` 保存修改。Host 自动继承发起聊天的模型与推理配置;Agent 不接收模型设置字段,也不需要查询或询问模型。后续模型调整由用户在流程详情中完成。AI 修改保留已有阶段的用户模型设置,新增 AI 阶段继承当前编辑聊天的配置。
8
+
9
+ 保存后就能创建任务,没有草稿、发布、启用或停用步骤。页面提供流程图;点击阶段打开 DSH 原生弹窗,可直接编辑执行要求或审核文本,点击保存或按 ⌘/Ctrl+Enter 提交。AI 阶段复用 DSH 输入框的 ModelSelect 组件切换模型和原生推理档位,点选立即保存,也可恢复使用 DSH 默认模型;切换模型不会丢失正在编辑的文本。模型目录复用 DSH 的 `session/modelCatalog`,不修改聊天或全局模型设置。阶段名称、类型、顺序及新增、删除仍通过聊天让 Agent 修改;人工节点没有模型配置。编辑流程只影响新任务,已有任务保留执行时的流程快照。
10
+
11
+ ## 首页与详情
12
+
13
+ - 首页流程行展示展开箭头、黑白图标、名称与任务数,创建任务入口作为最后一个子项放在任务列表末尾,随流程一起折叠。任务行用输入内容作为主文字,过长时省略,悬停或聚焦预览内容,点击查看全文,同时展示执行状态、当前步骤和更新时间。
14
+ - 首页直接展示表格,不设搜索和筛选;最后一行居中提供对话创建流程入口,空列表也使用同一入口。
15
+ - 流程详情展示说明与流程图,阶段要求和模型配置通过点击节点在弹窗中查看,不放任务列表和创建按钮。任务详情始终展示紧凑流程图,高亮当前阶段;点击节点在 DSH 原生居中弹窗查看该阶段的原生会话、成果或审核内容,不使用 Tab。通过面包屑返回流程或首页。
16
+ - 页面使用一个纵向滚动区域,内容自然延伸到底部。流程图使用 React Flow 自由画布,默认按 100% 展示;任务详情初始定位当前执行阶段,不显示内部滚动条。拖动或触控板双指滑动平移,鼠标滚轮、捏合或 ⌘/Ctrl 配合滚轮缩放,点击「查看全图」才缩放到完整流程。窗口尺寸及任务状态更新不重置用户的画布视角。
17
+
18
+ ## 执行任务
19
+
20
+ 在首页对应流程行点击 **创建任务**,直接在行内输入任务内容并发送,也可用 ⌘/Ctrl+Enter 提交。不填任务名称,不选择模型,不打开创建弹窗。阶段使用项目内该 Task 独有的产物目录作为默认工作目录,原项目绝对路径随任务传给 Agent,加载 DSH 默认 Agent 预设,工具和授权沿用 DSH。
21
+
22
+ 任务详情展示流程图和产物列表,点击节点打开 DSH 原生居中弹窗查看该阶段的详情与结果,复用 DSH 原生聊天视图查看思考、工具和回复。弹窗固定查看所点阶段,流程推进时不会跳转会话,当前执行节点仍独立高亮。人工审核节点在弹窗中展示绑定成果和审核操作。弹窗按内容和窗口尺寸适配,成果使用 DSH 原生 Markdown 排版,长文本在内容区滚动;Esc 或关闭按钮返回流程图;关闭不会取消任务。
23
+
24
+ 弹窗工作过程使用原生聊天滚动区域,页面其他详情继续自然滚动,不叠加过程记录列表。输入框不在任务页显示,DSH 原生工具授权组件保留;需要进入完整聊天时仍可点击 **打开执行会话**。查看过程不会重新下发阶段任务。
25
+
26
+ Workflow 不额外设置联网/文件/命令权限、工具次数、模型轮数、阶段总时长或输出 token 预算;Ultra 和子 Agent 是否可用由模型与 DSH 配置决定。
27
+
28
+ 同一任务的阶段依次执行。Workflow 最多同时运行两个 AI 阶段,分别来自不同项目目录;同一目录的任务排队。等待人工审核的任务不占执行名额。
29
+
30
+ ## 人工审核与异常处理
31
+
32
+ 流程含人工节点时,任务会停在该节点等待用户决定:
33
+
34
+ - **通过并继续**:接受当前保存的报告并继续。
35
+ - **打回重做**:填写意见,回到流程规定的 AI 步骤;保留历史报告。
36
+ - **重试**:已停止的失败任务重新执行当前阶段。
37
+ - **终止任务**:打开小确认弹窗后请求 DSH 停止;当前执行阶段会话标题也提供入口。“终止中”仍在等待停止确认。
38
+
39
+ DSH 重启或插件重载后,中断执行会保留为“需要处理”,不会自动重跑。点击 **核对旧执行**,先核对旧命令及外部操作已经停止,再勾选确认;强退宿主后,macOS 上的命令可能继续运行,新进程的作业清单为空并不代表旧操作已退出。Workflow 同时核对原生会话所有权、关联作业与原始输入身份;会话或作业仍工作时不能释放执行位置。核对不会向会话发送消息或取消后来追加的聊天。核对后,已请求终止的任务进入“已终止”,其他中断任务仍由用户选择重试当前阶段,上游已提交阶段不重跑。终止中的旧执行也可重新核对。
40
+
41
+ 已完成审核节点仍可查看决定时间及该次绑定的报告。任务界面显示当前审核状态,生成文档只保留内容与生成时点,不因批准而自动改写已审核文件。
42
+
43
+ 人工审核不提供 Agent 自动批准入口。报告缺失、断线或审核轮次变化时不能批准。文件修改不会因打回或终止自动回滚。
44
+
45
+ 删除入口位于流程或任务详情,使用小弹窗二次确认。首页行内不放删除按钮;尚未停止的执行不能删除或盲目重派。
46
+
47
+ 当前适配 DSH **0.2.2-rc.3**。后端变更需重载插件,前端刷新不足以替换执行模块。旧 SQLite 数据和历史快照保留,不迁移或覆盖看板数据。
48
+
49
+ ## 阶段交接与产物位置
50
+
51
+ 每个 AI 阶段/重试使用独立的 DSH 会话。阶段输入由本阶段要求、任务原始输入、所有仍有效的上游阶段交接摘要、产物索引和人工反馈组成;不再自动携带上游成果全文,也不会直接继承上一阶段的完整聊天历史或工具调用。
52
+
53
+ 阶段在完成本轮结果后,需在最终回复末尾附加 `workflow-handoff` Markdown 代码围栏,围栏中包含 `<workflow-handoff>` JSON:`conclusions`(每条含结论 text 与依据 evidence)、`openIssues`(缺口、分歧与不确定性)、`nextActions`(后续需读取、核查或执行的事项)。摘要目标为 300–600 中文字符/150–300 英文单词,最多接收 2400 个 JSON 字符;数字、单位、日期、标识与依据位置需明确。详细论证仍放在完整回复和产物文件中,不把之前报告全文再复制一遍。摘要由当前阶段在同一次执行中生成,不额外调用模型。Workflow 阅读界面隐藏保留围栏和内部编排输入;旧回复默认展示阶段报告,可展开原始会话。原始字节和 hash 保留,不改写持久化记录。
54
+
55
+ 调度器保留每个有效阶段自己的摘要,不反复改写成一份累积总结。交接同时包含完整报告相对路径、SHA-256、文件大小与当前 Task 的文件索引。后续阶段需按需读取重要结论的依据;没有摘要、摘要格式错误或过长时,`needsRead: true` 要求先读该报告全文,不截断或猜测关键结论,也不会仅因摘要格式问题让任务失败。被审核打回替代的旧摘要不再进入有效上下文;文件索引仍可能出现旧文件,存在并不代表结论有效。
56
+
57
+ 阶段最终回复保存为一个不可变文本附件,文件名为 `workflow-<attemptId>.txt`。Workflow 在当前 Profile 的 `workflow-poc/workflow.sqlite` 中按任务、阶段访问和执行尝试记录附件引用与 SHA-256。DSH 本地附件服务保存字节:`<DSH_HOME>/attachments/v1/files/<hash前两位>/<hash>/workflow-<attemptId>.txt`,底层内容对象位于 `file-objects/<hash前两位>/<hash>`。调度器核验有效附件内容后提取摘要;完整内容通过任务目录中的 `.workflow-results/<attemptId>.md` 按需读取。这些副本属于只读执行历史,不列入可删除的交付文件;副本缺失或被修改时,从已核验附件修复,不影响后续阶段。审核打回后旧成果仍留作历史,但从有效上游输入中排除。
58
+
59
+ 每个 Task 的产物目录为 `<项目>/.dsh/workflow-artifacts/<taskId>/`。创建时建立目录;同一 Task 的各阶段、重试和返工共用它,不同 Task 使用不同目录。阶段以此为默认工作目录,生成文件默认落到这里;原项目路径仍可用于读取资料和按需求修改代码,工具与授权不变。每次成功阶段的最终回复也保存到 `.workflow-results/<attemptId>.md`,不同执行尝试不会覆盖彼此。历史任务已有的项目文件不猜测归属、不自动搬迁。
60
+
61
+ 任务详情的产物列表递归显示该目录中的文件并自动刷新,跳过符号链接;文件接口校验路径归属,不能跨 Task 取文件。点击文件在当前任务中打开 DSH 原生 Modal,Markdown 与代码使用 DSH 的 MarkdownText / CodeBlock,图片、音视频、PDF 使用浏览器能力,读取复用 DSH 已认证的 `/api/file`。预览不切换会话。弹窗仅提供文件预览,其他格式可从产物目录查看。目录仍可通过 DSH 原生路径能力打开。文件大小限制沿用 DSH 文件读取接口,不新增 Workflow 限额。
62
+
63
+ ## 删除产物与历史优化
64
+
65
+ 每个产物行可删除单个文件,操作前弹窗二次确认。删除校验文件仍属于该 Task 且版本与确认时一致;文件被执行阶段更新时需先刷新再确认。不会递归删除目录,也不会删除数据库中的执行、审核记录或 DSH 不可变成果附件。
66
+
67
+ 删除任务时,确认弹窗会提示同时永久删除该任务产物目录及其中的所有文件(包含各阶段回复副本)。正在执行或尚未确认停止的任务需先终止,才能删除。只清理该 Task 的独立目录,不触及项目其他文件、其他 Task 的目录或符号链接指向的文件。删除意图先提交到数据库并停止调度,再异步清理目录;清理失败会提示后台继续处理,重启后也会恢复清理。数据库提交失败不会提前删除文件。执行、审核记录与 DSH 不可变成果附件仍保留。
68
+
69
+ 在流程详情点击「根据历史优化」会打开新聊天并填入预置分析要求,不自动执行任务。Agent 用 `workflow_list_tasks` 读取此流程的历史摘要,按 workflowVersionId / versionNumber 区分版本,再用 `workflow_get_task` 读取代表性任务的旧阶段、结果索引、错误和审核意见。需要完整报告时显式传入 `includeOutputText: true`,阶段对话通过 `workflow_get_stage_trace` 按需读取。保存优化只影响未来新建任务;正在运行、等待审核或已经结束的任务继续使用原快照,旧阶段 ID、产物目录和记录均不迁移。
70
+
71
+ 需要速度分析时,`workflow_get_stage_trace` 只读该 Task 指定阶段/执行尝试的持久化会话日志:用户与 AI 消息、记录下来的思考文本、工具参数与结果、阶段总耗时、模型轮次与首输出等待、token/cache 数据、重试、压缩和授权事件。对话按 fromSeq / limit 分页,概览覆盖整次执行;后续在同一会话追加的无关聊天不会混入阶段记录。它不恢复或重新运行 Agent,也不返回连接配置与传输请求头。
72
+
73
+ 工具耗时是 tool/call 到 tool/result 的墙钟间隔,可能包含排队、授权或等待子任务。observedToolWallMs 合并重叠区间,不能把并行调用耗时简单相加;模型耗时从 step/start 计算,可能包含准备与重试等待。没有 token、时间或日志的数据保持未知;服务端内部排队、工具内部子步骤、独立子 Agent 的内部聊天不能仅凭阶段主会话自动得出。执行中日志可能尚未刷新到持久化存储。
74
+
75
+ ## 执行收尾与刷新
76
+
77
+ Workflow 不设置阶段回复大小或组合输入长度的执行上限,模型和上下文能力沿用 DSH。阶段已经执行完成后,附件、报告副本或数据库暂时无法保存时,只重试保存,不重新调用模型;核对入口可处理原生会话已空闲但数据库尚未收尾的任务。无法确认执行已停止时仍需读取 DSH 的会话所有权和工作状态,避免重复执行。
78
+
79
+ 任务状态接口默认只返回报告索引。阶段弹窗打开后才读取报告正文,历史报告按需展开;交付文件区不混入阶段报告与旧尝试。活动任务轮询文件索引,任务结束后仅在进入页面、阶段状态变化或手动刷新时更新。列表连接短暂失败后会自动重新连接。折叠流程时,父行仍显示进行中和待处理的任务数量。
80
+
81
+ ## 数据与备份
82
+
83
+ 同时备份当前 Profile 的 `workflow-poc/workflow.sqlite`、DSH 附件存储,以及各项目的 `.dsh/workflow-artifacts/` 目录。停用插件后备份,或使用 SQLite 一致性备份;不要直接复制运行中的数据库而遗漏 WAL。保留 `workflow-poc` 历史目录名是为了继续读取已有记录,不做无必要迁移。
84
+
85
+ 看板数据独立保存,见[看板备份说明](guide.zh.md#数据与备份)。任务目录删除后,Workflow 不提供恢复功能。
86
+
87
+ 界面控件、内置错误和日期跟随 DSH 的中文/英文设置;用户命名、阶段要求、反馈与产物保持原文。[English guide](workflow-guide.en.md)。
@@ -0,0 +1,303 @@
1
+ -- Workflow schema v1: canonical bootstrap used by workflow/store.js.
2
+ -- Independent of Kanban. Verified with in-memory and persistent SQLite tests.
3
+ -- This is not an upgrade migration; domain transitions require the store command protocol.
4
+ PRAGMA foreign_keys = ON;
5
+
6
+ CREATE TABLE wf_workflows (
7
+ id TEXT PRIMARY KEY NOT NULL,
8
+ workspace_id TEXT NOT NULL,
9
+ root_path_snapshot TEXT NOT NULL,
10
+ execution_scope TEXT NOT NULL,
11
+ name TEXT NOT NULL CHECK(length(trim(name)) > 0),
12
+ accepting_tasks INTEGER NOT NULL DEFAULT 0 CHECK(accepting_tasks IN (0, 1)),
13
+ draft_json TEXT NOT NULL CHECK(json_valid(draft_json) AND json_type(draft_json) = 'object'),
14
+ draft_revision INTEGER NOT NULL CHECK(draft_revision >= 1),
15
+ published_version_id TEXT,
16
+ created_at INTEGER NOT NULL,
17
+ updated_at INTEGER NOT NULL,
18
+ CHECK(accepting_tasks = 0 OR published_version_id IS NOT NULL),
19
+ FOREIGN KEY(published_version_id, id) REFERENCES wf_versions(id, workflow_id)
20
+ DEFERRABLE INITIALLY DEFERRED
21
+ ) STRICT;
22
+
23
+ CREATE TABLE wf_versions (
24
+ id TEXT PRIMARY KEY NOT NULL,
25
+ workflow_id TEXT NOT NULL REFERENCES wf_workflows(id),
26
+ version_number INTEGER NOT NULL CHECK(version_number >= 1),
27
+ definition_json TEXT NOT NULL CHECK(json_valid(definition_json) AND json_type(definition_json) = 'object'),
28
+ definition_hash TEXT NOT NULL CHECK(length(definition_hash) = 64 AND definition_hash NOT GLOB '*[^0-9a-f]*'),
29
+ published_by_json TEXT NOT NULL CHECK(json_valid(published_by_json)),
30
+ published_at INTEGER NOT NULL,
31
+ UNIQUE(workflow_id, version_number),
32
+ UNIQUE(id, workflow_id)
33
+ ) STRICT;
34
+
35
+ CREATE TABLE wf_tasks (
36
+ id TEXT PRIMARY KEY NOT NULL,
37
+ workflow_id TEXT NOT NULL,
38
+ workflow_version_id TEXT NOT NULL,
39
+ title TEXT NOT NULL CHECK(length(trim(title)) > 0),
40
+ input_json TEXT NOT NULL CHECK(json_valid(input_json) AND json_type(input_json) = 'object'),
41
+ execution_config_json TEXT NOT NULL CHECK(json_valid(execution_config_json) AND json_type(execution_config_json) = 'object'),
42
+ supplements_json TEXT NOT NULL DEFAULT '[]' CHECK(json_valid(supplements_json) AND json_type(supplements_json) = 'array'),
43
+ state TEXT NOT NULL CHECK(state IN ('queued', 'running', 'waiting_review', 'needs_attention', 'pausing', 'paused', 'terminating', 'completed', 'terminated')),
44
+ current_visit_id TEXT NOT NULL,
45
+ revision INTEGER NOT NULL CHECK(revision >= 1),
46
+ attention_json TEXT CHECK(attention_json IS NULL OR json_valid(attention_json)),
47
+ source_task_id TEXT REFERENCES wf_tasks(id),
48
+ queued_at INTEGER,
49
+ created_at INTEGER NOT NULL,
50
+ updated_at INTEGER NOT NULL,
51
+ finished_at INTEGER,
52
+ CHECK((state IN ('completed', 'terminated')) = (finished_at IS NOT NULL)),
53
+ CHECK(state <> 'queued' OR queued_at IS NOT NULL),
54
+ CHECK(state <> 'needs_attention' OR attention_json IS NOT NULL),
55
+ FOREIGN KEY(workflow_version_id, workflow_id) REFERENCES wf_versions(id, workflow_id),
56
+ FOREIGN KEY(current_visit_id, id) REFERENCES wf_stage_visits(id, task_id)
57
+ DEFERRABLE INITIALLY DEFERRED
58
+ ) STRICT;
59
+ CREATE INDEX wf_tasks_queue ON wf_tasks(state, queued_at, id);
60
+ CREATE INDEX wf_tasks_by_workflow ON wf_tasks(workflow_id, created_at);
61
+
62
+ CREATE TABLE wf_stage_visits (
63
+ id TEXT PRIMARY KEY NOT NULL,
64
+ task_id TEXT NOT NULL REFERENCES wf_tasks(id),
65
+ stage_id TEXT NOT NULL,
66
+ ordinal INTEGER NOT NULL CHECK(ordinal >= 1),
67
+ entered_by TEXT NOT NULL CHECK(entered_by IN ('start', 'advance', 'rework')),
68
+ caused_by_review_id TEXT,
69
+ outcome TEXT NOT NULL CHECK(outcome IN ('open', 'succeeded', 'returned', 'terminated')),
70
+ accepted_attempt_id TEXT,
71
+ superseded_by_review_id TEXT,
72
+ opened_at INTEGER NOT NULL,
73
+ closed_at INTEGER,
74
+ CHECK((outcome <> 'open') = (closed_at IS NOT NULL)),
75
+ CHECK(outcome = 'succeeded' OR accepted_attempt_id IS NULL),
76
+ CHECK((entered_by = 'rework') = (caused_by_review_id IS NOT NULL)),
77
+ UNIQUE(task_id, ordinal),
78
+ UNIQUE(id, task_id),
79
+ FOREIGN KEY(accepted_attempt_id, id) REFERENCES wf_attempts(id, visit_id)
80
+ DEFERRABLE INITIALLY DEFERRED,
81
+ FOREIGN KEY(caused_by_review_id, task_id) REFERENCES wf_reviews(id, task_id)
82
+ DEFERRABLE INITIALLY DEFERRED,
83
+ FOREIGN KEY(superseded_by_review_id, task_id) REFERENCES wf_reviews(id, task_id)
84
+ DEFERRABLE INITIALLY DEFERRED
85
+ ) STRICT;
86
+ CREATE UNIQUE INDEX wf_one_current_visit_per_stage ON wf_stage_visits(task_id, stage_id)
87
+ WHERE superseded_by_review_id IS NULL;
88
+ CREATE UNIQUE INDEX wf_one_open_visit_per_task ON wf_stage_visits(task_id)
89
+ WHERE outcome = 'open';
90
+
91
+ CREATE TABLE wf_attempts (
92
+ id TEXT PRIMARY KEY NOT NULL,
93
+ task_id TEXT NOT NULL,
94
+ visit_id TEXT NOT NULL,
95
+ attempt_number INTEGER NOT NULL CHECK(attempt_number >= 1),
96
+ state TEXT NOT NULL CHECK(state IN ('prepared', 'running', 'unknown', 'succeeded', 'failed', 'cancelled')),
97
+ input_bundle_json TEXT NOT NULL CHECK(json_valid(input_bundle_json) AND json_type(input_bundle_json) = 'object'),
98
+ executor_snapshot_json TEXT NOT NULL CHECK(json_valid(executor_snapshot_json) AND json_type(executor_snapshot_json) = 'object'),
99
+ prompt_request_id TEXT NOT NULL UNIQUE,
100
+ prompt_payload_json TEXT NOT NULL CHECK(json_valid(prompt_payload_json) AND json_type(prompt_payload_json) = 'object'),
101
+ prompt_payload_hash TEXT NOT NULL CHECK(length(prompt_payload_hash) = 64 AND prompt_payload_hash NOT GLOB '*[^0-9a-f]*'),
102
+ session_id TEXT UNIQUE,
103
+ message_id TEXT,
104
+ turn_number INTEGER CHECK(turn_number IS NULL OR turn_number >= 0),
105
+ last_observed_seq INTEGER CHECK(last_observed_seq IS NULL OR last_observed_seq >= 0),
106
+ accepted_at INTEGER,
107
+ claimed_at INTEGER,
108
+ host_end_json TEXT CHECK(host_end_json IS NULL OR json_valid(host_end_json)),
109
+ result_json TEXT CHECK(result_json IS NULL OR (json_valid(result_json) AND json_type(result_json) = 'object')),
110
+ error_json TEXT CHECK(error_json IS NULL OR json_valid(error_json)),
111
+ reconciliation_json TEXT CHECK(reconciliation_json IS NULL OR json_valid(reconciliation_json)),
112
+ cancel_requested_at INTEGER,
113
+ cancel_reason TEXT,
114
+ quiesced_at INTEGER,
115
+ created_at INTEGER NOT NULL,
116
+ settled_at INTEGER,
117
+ CHECK((state IN ('succeeded', 'failed', 'cancelled')) = (settled_at IS NOT NULL)),
118
+ CHECK(state NOT IN ('succeeded', 'failed', 'cancelled') OR quiesced_at IS NOT NULL),
119
+ CHECK(state <> 'succeeded' OR (result_json IS NOT NULL AND COALESCE(json_type(result_json, '$.artifactIds') = 'array', 0))),
120
+ CHECK(quiesced_at IS NULL OR state NOT IN ('prepared', 'running')),
121
+ CHECK(turn_number IS NULL OR session_id IS NOT NULL),
122
+ UNIQUE(visit_id, attempt_number),
123
+ UNIQUE(id, visit_id),
124
+ UNIQUE(id, task_id),
125
+ FOREIGN KEY(visit_id, task_id) REFERENCES wf_stage_visits(id, task_id)
126
+ ) STRICT;
127
+ CREATE UNIQUE INDEX wf_one_unsettled_attempt_per_task ON wf_attempts(task_id)
128
+ WHERE state IN ('prepared', 'running', 'unknown');
129
+
130
+ CREATE TABLE wf_artifacts (
131
+ id TEXT PRIMARY KEY NOT NULL,
132
+ task_id TEXT NOT NULL,
133
+ attempt_id TEXT NOT NULL,
134
+ output_key TEXT NOT NULL CHECK(length(trim(output_key)) > 0),
135
+ label TEXT NOT NULL,
136
+ media_type TEXT NOT NULL,
137
+ content_hash TEXT NOT NULL CHECK(length(content_hash) = 64 AND content_hash NOT GLOB '*[^0-9a-f]*'),
138
+ byte_length INTEGER NOT NULL CHECK(byte_length >= 0),
139
+ snapshot_ref TEXT NOT NULL CHECK(length(snapshot_ref) > 0),
140
+ created_at INTEGER NOT NULL,
141
+ UNIQUE(attempt_id, output_key),
142
+ FOREIGN KEY(attempt_id, task_id) REFERENCES wf_attempts(id, task_id)
143
+ ) STRICT;
144
+
145
+ CREATE TABLE wf_reviews (
146
+ id TEXT PRIMARY KEY NOT NULL,
147
+ task_id TEXT NOT NULL,
148
+ visit_id TEXT NOT NULL UNIQUE,
149
+ subject_json TEXT NOT NULL CHECK(json_valid(subject_json) AND json_type(subject_json) = 'object'),
150
+ subject_hash TEXT NOT NULL CHECK(length(subject_hash) = 64 AND subject_hash NOT GLOB '*[^0-9a-f]*'),
151
+ return_stage_id TEXT NOT NULL,
152
+ state TEXT NOT NULL CHECK(state IN ('pending', 'approved', 'returned', 'terminated')),
153
+ feedback TEXT,
154
+ decided_by_json TEXT CHECK(decided_by_json IS NULL OR json_valid(decided_by_json)),
155
+ decision_request_id TEXT,
156
+ requested_at INTEGER NOT NULL,
157
+ decided_at INTEGER,
158
+ CHECK((state = 'pending') = (decided_at IS NULL)),
159
+ CHECK(state = 'pending' OR (decided_by_json IS NOT NULL AND decision_request_id IS NOT NULL)),
160
+ CHECK(state <> 'returned' OR (feedback IS NOT NULL AND length(trim(feedback)) > 0)),
161
+ UNIQUE(id, task_id),
162
+ FOREIGN KEY(visit_id, task_id) REFERENCES wf_stage_visits(id, task_id)
163
+ ) STRICT;
164
+
165
+ -- A prepared Attempt is the durable dispatch intent: no generic outbox is added.
166
+ -- This slot is NOT a time-expiring lease. Heartbeat absence is not stop evidence.
167
+ CREATE TABLE wf_execution_slots (
168
+ execution_scope TEXT PRIMARY KEY NOT NULL,
169
+ attempt_id TEXT NOT NULL UNIQUE REFERENCES wf_attempts(id),
170
+ owner_instance_id TEXT NOT NULL,
171
+ owner_token TEXT NOT NULL,
172
+ acquired_at INTEGER NOT NULL,
173
+ last_observed_at INTEGER NOT NULL
174
+ ) STRICT;
175
+
176
+ CREATE TABLE wf_command_receipts (
177
+ namespace TEXT NOT NULL,
178
+ request_id TEXT NOT NULL,
179
+ operation TEXT NOT NULL,
180
+ payload_hash TEXT NOT NULL CHECK(length(payload_hash) = 64 AND payload_hash NOT GLOB '*[^0-9a-f]*'),
181
+ actor_json TEXT NOT NULL CHECK(json_valid(actor_json)),
182
+ response_json TEXT NOT NULL CHECK(json_valid(response_json)),
183
+ committed_at INTEGER NOT NULL,
184
+ PRIMARY KEY(namespace, request_id)
185
+ ) STRICT;
186
+
187
+ CREATE TABLE wf_task_events (
188
+ id TEXT PRIMARY KEY NOT NULL,
189
+ task_id TEXT NOT NULL REFERENCES wf_tasks(id),
190
+ sequence INTEGER NOT NULL CHECK(sequence >= 1),
191
+ task_revision INTEGER NOT NULL CHECK(task_revision >= 1),
192
+ kind TEXT NOT NULL,
193
+ actor_json TEXT NOT NULL CHECK(json_valid(actor_json)),
194
+ data_json TEXT NOT NULL CHECK(json_valid(data_json)),
195
+ request_id TEXT,
196
+ created_at INTEGER NOT NULL,
197
+ UNIQUE(task_id, sequence)
198
+ ) STRICT;
199
+
200
+ -- Minimum structural guards. See the document for command-level invariants.
201
+ CREATE TRIGGER wf_workflow_binding_immutable BEFORE UPDATE OF id, workspace_id, root_path_snapshot, execution_scope ON wf_workflows
202
+ BEGIN SELECT RAISE(ABORT, 'workflow identity and workspace binding are immutable'); END;
203
+ CREATE TRIGGER wf_version_no_update BEFORE UPDATE ON wf_versions
204
+ BEGIN SELECT RAISE(ABORT, 'published version is immutable'); END;
205
+ CREATE TRIGGER wf_version_no_delete BEFORE DELETE ON wf_versions
206
+ BEGIN SELECT RAISE(ABORT, 'published history is retained'); END;
207
+ CREATE TRIGGER wf_task_binding_immutable BEFORE UPDATE OF id, workflow_id, workflow_version_id, input_json, execution_config_json, source_task_id ON wf_tasks
208
+ BEGIN SELECT RAISE(ABORT, 'task execution snapshot is immutable'); END;
209
+ CREATE TRIGGER wf_task_terminal BEFORE UPDATE ON wf_tasks
210
+ WHEN OLD.state IN ('completed', 'terminated')
211
+ BEGIN SELECT RAISE(ABORT, 'terminal task cannot be reopened'); END;
212
+
213
+ CREATE TRIGGER wf_visit_valid_stage BEFORE INSERT ON wf_stage_visits
214
+ WHEN NOT EXISTS (
215
+ SELECT 1 FROM wf_tasks t JOIN wf_versions v ON v.id = t.workflow_version_id,
216
+ json_each(v.definition_json, '$.stages') s
217
+ WHERE t.id = NEW.task_id AND json_extract(s.value, '$.id') = NEW.stage_id
218
+ )
219
+ BEGIN SELECT RAISE(ABORT, 'stage must belong to the task version'); END;
220
+ CREATE TRIGGER wf_visit_identity_immutable BEFORE UPDATE OF id, task_id, stage_id, ordinal, entered_by, caused_by_review_id, opened_at ON wf_stage_visits
221
+ BEGIN SELECT RAISE(ABORT, 'stage visit identity is immutable'); END;
222
+ CREATE TRIGGER wf_visit_superseded_once BEFORE UPDATE OF superseded_by_review_id ON wf_stage_visits
223
+ WHEN OLD.superseded_by_review_id IS NOT NULL
224
+ BEGIN SELECT RAISE(ABORT, 'do not rewrite the previous rework cause'); END;
225
+ CREATE TRIGGER wf_visit_close_once BEFORE UPDATE OF outcome, accepted_attempt_id, closed_at ON wf_stage_visits
226
+ WHEN OLD.outcome <> 'open'
227
+ BEGIN SELECT RAISE(ABORT, 'settled visit outcome is immutable'); END;
228
+ CREATE TRIGGER wf_visit_accept_success BEFORE UPDATE OF accepted_attempt_id ON wf_stage_visits
229
+ WHEN NEW.accepted_attempt_id IS NOT NULL AND NOT EXISTS (
230
+ SELECT 1 FROM wf_attempts a WHERE a.id = NEW.accepted_attempt_id AND a.visit_id = NEW.id AND a.state = 'succeeded'
231
+ )
232
+ BEGIN SELECT RAISE(ABORT, 'only a successful attempt of this visit can be accepted'); END;
233
+
234
+ CREATE TRIGGER wf_attempt_agent_only BEFORE INSERT ON wf_attempts
235
+ WHEN NOT EXISTS (
236
+ SELECT 1 FROM wf_stage_visits sv JOIN wf_tasks t ON t.id = sv.task_id JOIN wf_versions v ON v.id = t.workflow_version_id,
237
+ json_each(v.definition_json, '$.stages') s
238
+ WHERE sv.id = NEW.visit_id AND sv.task_id = NEW.task_id AND sv.outcome = 'open'
239
+ AND sv.superseded_by_review_id IS NULL AND json_extract(s.value, '$.id') = sv.stage_id AND json_extract(s.value, '$.kind') = 'agent'
240
+ )
241
+ BEGIN SELECT RAISE(ABORT, 'attempt requires an open current agent visit'); END;
242
+ CREATE TRIGGER wf_attempt_identity_immutable BEFORE UPDATE OF id, task_id, visit_id, attempt_number, input_bundle_json, executor_snapshot_json, prompt_request_id, prompt_payload_json, prompt_payload_hash ON wf_attempts
243
+ BEGIN SELECT RAISE(ABORT, 'attempt identity and input are immutable'); END;
244
+ CREATE TRIGGER wf_attempt_session_once BEFORE UPDATE OF session_id ON wf_attempts
245
+ WHEN OLD.session_id IS NOT NULL AND NEW.session_id IS NOT OLD.session_id
246
+ BEGIN SELECT RAISE(ABORT, 'attempt cannot switch sessions after binding'); END;
247
+ CREATE TRIGGER wf_attempt_quiescence_monotonic BEFORE UPDATE OF quiesced_at ON wf_attempts
248
+ WHEN OLD.quiesced_at IS NOT NULL AND NEW.quiesced_at IS NOT OLD.quiesced_at
249
+ BEGIN SELECT RAISE(ABORT, 'quiescence evidence cannot be withdrawn'); END;
250
+ CREATE TRIGGER wf_attempt_settle_once BEFORE UPDATE ON wf_attempts
251
+ WHEN OLD.state IN ('succeeded', 'failed', 'cancelled')
252
+ BEGIN SELECT RAISE(ABORT, 'known terminal attempt is immutable; append late evidence to task events'); END;
253
+ CREATE TRIGGER wf_artifact_before_settlement BEFORE INSERT ON wf_artifacts
254
+ WHEN (SELECT state FROM wf_attempts WHERE id = NEW.attempt_id) IN ('succeeded', 'failed', 'cancelled')
255
+ BEGIN SELECT RAISE(ABORT, 'final output set is frozen after attempt settlement'); END;
256
+ CREATE TRIGGER wf_artifact_no_update BEFORE UPDATE ON wf_artifacts
257
+ BEGIN SELECT RAISE(ABORT, 'artifact snapshot is immutable'); END;
258
+ CREATE TRIGGER wf_artifact_no_delete BEFORE DELETE ON wf_artifacts
259
+ BEGIN SELECT RAISE(ABORT, 'artifact history is retained'); END;
260
+ CREATE TRIGGER wf_review_stage_only BEFORE INSERT ON wf_reviews
261
+ WHEN NOT EXISTS (
262
+ SELECT 1 FROM wf_stage_visits sv JOIN wf_tasks t ON t.id = sv.task_id JOIN wf_versions v ON v.id = t.workflow_version_id,
263
+ json_each(v.definition_json, '$.stages') s
264
+ WHERE sv.id = NEW.visit_id AND sv.task_id = NEW.task_id AND sv.outcome = 'open'
265
+ AND sv.superseded_by_review_id IS NULL AND json_extract(s.value, '$.id') = sv.stage_id AND json_extract(s.value, '$.kind') = 'review'
266
+ )
267
+ BEGIN SELECT RAISE(ABORT, 'review requires an open review visit'); END;
268
+ CREATE TRIGGER wf_review_subject_immutable BEFORE UPDATE OF id, task_id, visit_id, subject_json, subject_hash, return_stage_id, requested_at ON wf_reviews
269
+ BEGIN SELECT RAISE(ABORT, 'review target is immutable'); END;
270
+ CREATE TRIGGER wf_review_decide_once BEFORE UPDATE ON wf_reviews
271
+ WHEN OLD.state <> 'pending'
272
+ BEGIN SELECT RAISE(ABORT, 'review already decided'); END;
273
+
274
+ CREATE TRIGGER wf_slot_scope BEFORE INSERT ON wf_execution_slots
275
+ WHEN NOT EXISTS (
276
+ SELECT 1 FROM wf_attempts a JOIN wf_tasks t ON t.id = a.task_id JOIN wf_workflows w ON w.id = t.workflow_id
277
+ WHERE a.id = NEW.attempt_id AND w.execution_scope = NEW.execution_scope
278
+ AND a.state IN ('prepared', 'running', 'unknown') AND a.quiesced_at IS NULL
279
+ )
280
+ BEGIN SELECT RAISE(ABORT, 'slot must match an unquiesced attempt in this execution scope'); END;
281
+ CREATE TRIGGER wf_slot_no_rebind BEFORE UPDATE OF execution_scope, attempt_id ON wf_execution_slots
282
+ BEGIN SELECT RAISE(ABORT, 'release the old slot before acquiring a different attempt'); END;
283
+ CREATE TRIGGER wf_slot_release_proof BEFORE DELETE ON wf_execution_slots
284
+ WHEN (SELECT quiesced_at FROM wf_attempts WHERE id = OLD.attempt_id) IS NULL
285
+ BEGIN SELECT RAISE(ABORT, 'cannot release slot without quiescence evidence'); END;
286
+ CREATE TRIGGER wf_receipt_no_update BEFORE UPDATE ON wf_command_receipts
287
+ BEGIN SELECT RAISE(ABORT, 'command receipt is immutable'); END;
288
+ CREATE TRIGGER wf_receipt_no_delete BEFORE DELETE ON wf_command_receipts
289
+ BEGIN SELECT RAISE(ABORT, 'idempotency receipt is retained'); END;
290
+ CREATE TRIGGER wf_event_no_update BEFORE UPDATE ON wf_task_events
291
+ BEGIN SELECT RAISE(ABORT, 'audit events are append only'); END;
292
+ CREATE TRIGGER wf_event_no_delete BEFORE DELETE ON wf_task_events
293
+ BEGIN SELECT RAISE(ABORT, 'audit events are append only'); END;
294
+ CREATE TRIGGER wf_workflow_no_delete BEFORE DELETE ON wf_workflows
295
+ BEGIN SELECT RAISE(ABORT, 'disable a workflow; do not delete its history'); END;
296
+ CREATE TRIGGER wf_task_no_delete BEFORE DELETE ON wf_tasks
297
+ BEGIN SELECT RAISE(ABORT, 'task history is retained'); END;
298
+ CREATE TRIGGER wf_visit_no_delete BEFORE DELETE ON wf_stage_visits
299
+ BEGIN SELECT RAISE(ABORT, 'visit history is retained'); END;
300
+ CREATE TRIGGER wf_attempt_no_delete BEFORE DELETE ON wf_attempts
301
+ BEGIN SELECT RAISE(ABORT, 'attempt history is retained'); END;
302
+ CREATE TRIGGER wf_review_no_delete BEFORE DELETE ON wf_reviews
303
+ BEGIN SELECT RAISE(ABORT, 'review history is retained'); END;
@@ -0,0 +1,82 @@
1
+ # Workflow 实现与验证状态
2
+
3
+ Workflow 是 Kanban 内的模式,沿用工作区切换、主题和原有面板边距。首页以流程和子任务组成二级列表,流程详情只展示定义、阶段要求与模型;任务详情始终展示流程图,高亮当前阶段,点击节点通过 DSH Modal 查看该阶段的原生会话、成果和审核。
4
+
5
+ ## 模型与执行
6
+
7
+ AI 阶段的 `modelSelection` 保存 provider、model 和可选 reasoningEffort。Agent 创建新阶段时继承当前聊天的真实模型配置,创建与修改工具不提供模型参数;后续用户在流程阶段弹窗中复用 DSH ModelSelect 调整模型与推理档位。模型不是任务选项,创建任务只提交流程版本与输入内容。
8
+
9
+ runner 按任务所绑定的流程版本选择各阶段模型,Attempt 快照记录实际选择。流程修改、全局默认模型变化和人工返工不会改写已有任务版本。未指定模型的旧阶段沿用创建任务时保存的 DSH 默认配置;旧 SQLite 数据和配置不迁移。旧 API 的任务名称与模型字段仍可被解析,但新的任务模型由流程阶段决定。
10
+
11
+ 执行采用项目目录、DSH 默认 Agent 预设、原生工具与授权。Workflow 负责调度、成果核验、人工审核、返工和终止,不另设工具权限或模型轮数、工具次数、阶段总时长、输出 token 预算。成果仍校验持久化 Session、请求对应关系、正常结束和附件 hash;未确认停止的旧执行不会自动重派。
12
+
13
+ ## 界面
14
+
15
+ 创建任务入口是流程下最后一个子项,随流程一起折叠;展开行内输入框即可发送,也支持 ⌘/Ctrl+Enter;没有任务名称或模型字段。输入内容在列表、标题和面包屑中省略显示,列表和标题支持 Tooltip。流程详情没有任务列表或创建按钮,也没有草稿、发布、启停能力。
16
+
17
+ 任务详情不使用 Tab。选中的 AI 阶段通过原生 SessionReference、`conversation.content` 与聊天视图展示模型公开的推理摘要、工具和回复;阶段说明、成果及历史记录与原生会话共用滚动区域。弹窗固定查看所点阶段,不随执行推进切换会话;当前执行节点仍独立高亮。查看不会重新下发任务,关闭释放本地会话引用、恢复节点焦点。阶段使用 DSH Modal,窄屏全屏,Esc 关闭。人工审核节点展示绑定成果和审核控件;反馈、断线、成果缺失、轮次更新与不可用返工目标的保护均保留。
18
+
19
+ 删除仍位于详情页,用小弹窗二次确认。常规界面回归使用隔离数据;真实任务执行须在用户明确授权的测试范围内进行。
20
+
21
+ ## 自动化与内核检查(更新于 2026-11-15)
22
+
23
+ - 39 个测试文件,613 项通过、3 项跳过;类型、schema、pipeline、构建、bundle、包内容与 diff 格式检查通过。
24
+ - 故障测试覆盖落库重试而不重跑模型、附件存储失败恢复、已空闲但未收尾的原生执行终止、长输入与大报告、删除提交失败不删文件、跨重开恢复清理、目录链接拒绝与失败清理重试。保存失败不新增对其他工作区的全局执行阻塞。
25
+ - 状态接口不读取报告正文;显式读取报告与人工批准仍核验不可变附件。只读阶段报告不进入交付文件列表,不允许通过交付文件接口删除;损坏或缺失的内部副本从核验后的附件修复。
26
+ - `scripts/check-workflow-executor.mjs` 使用安装版 DSH 的真实 AgentLoop、工具执行器和 JSONL,模型与预设为本地夹具。验证阶段模型、摘要与索引交接、按需读取原报告、原生停止证明、取消排空、工具输出 JSON,以及宿主 guard 与 32 次工具调用/33 轮执行。
27
+ - 在隔离页面加载当前 Workflow 前端组件及安装版 DSH 的真实 React、Modal、Tooltip、Markdown 与共享样式,使用明确标记的测试数据检查折叠汇总、长输入、审核与失败弹窗、交付文件分类。默认宽度及 390px 窄面板无页面横向溢出;长报告弹窗只存在一个纵向滚动区域,决定区位于报告之前,多报告默认只展开最后一份。读取了实际 computed styles 确认字体与布局。
28
+ - 上述隔离检查完成时,现有 DSH 桌面端确认本地客户端和 Host 可正常加载,真实任务列表为空;此后在用户明确授权下,完成了下述真实模型验收。
29
+
30
+ ### 真实模型与桌面端验收(2026-11-14)
31
+
32
+ 环境为现有 DSH 桌面端 `0.2.2-rc.3`、本地 Kanban 包 `1.11.2`,两个流程的 AI 阶段均使用 `openai-codex / gpt-6.1-sol / high`。输入是两组明确标记的虚构项目周报,调用真实模型和原生工具。任务经已认证的 DSH 接口创建,人工决定全部通过实际 GUI 操作。测试记录和产物已保留,没有删除其他任务或重启 DSH。
33
+
34
+ | 测试 | 任务 ID | 实际结果 |
35
+ | --- | --- | --- |
36
+ | 无人工审核:提取 → 摘要 | `e6a7ffe5-1452-46f4-ad04-10c60033431c` | 两阶段自动推进并完成;模型执行约 91.7 秒;没有人工决定 |
37
+ | 人工审核:提取 → 初审 → 摘要 → 终审 | `6661ef92-9923-4f45-ade4-fb060d7a68d9` | 初审停住,界面打回提取阶段;返工后批准才进入摘要,终审再次停住,界面批准后完成;共三次 AI 执行,约 165.9 秒,不含排队和人工等待 |
38
+
39
+ - 两个任务最终均为 `completed`,共五次 Attempt 全部成功,错误与待处理事项为空;人工记录依次为 `returned / approved / approved`。
40
+ - 打回保留原始报告,原件标记为非当前有效;新报告逐项落实反馈,负责人、截止日期和原文依据在同一行动项,未知的预算与部署窗口没有被补造。终审通过没有重新执行模型。
41
+ - 五份报告均重新读取并通过 SHA-256 与保存清单核验,五个交接摘要均可由生产解析器读取;最终摘要保留了数量、75% 完成率、计划日期、上线条件和未确认事项。
42
+ - 两个任务都生成 `验收摘要.md`,分别位于 `.dsh/workflow-artifacts/<taskId>/`。实际路径、内容和 hash 不同,互不串写;交付列表各显示一份文件,内部阶段快照未混入交付列表。
43
+ - 真实桌面端确认阶段弹窗、初审打回与批准、终审批准、任务完成状态,以及原地 Markdown 文件预览与纵向滚动。不需要切换到聊天会话查看文件。
44
+
45
+ ### 实际故障注入与修复(2026-11-14 至 11-15)
46
+
47
+ 故障注入运行于独立临时 Profile,加载安装版 DSH `0.2.2-rc.3`、真实 Codex 订阅模型及本地 Kanban 包。它与现有桌面端的任务、数据库和工作目录隔离;没有关闭系统网络、强退用户桌面 DSH 或修改原生工具与授权。下表的网络、停止及恢复均调用真实模型和原生工具,不是本地模型夹具。
48
+
49
+ | 场景 | 任务 ID | 注入与实际结果 |
50
+ | --- | --- | --- |
51
+ | 模型请求断网 | `7bc153dc-910a-4135-bd8f-f4f503c134a1` | 在真实模型 SSE 已收到 24 字节后切断响应,并使该实例的后续连接失败。DSH 原生重试结束后停止在当前阶段,无成果提交;恢复连接,手动重试同一任务后完成 |
52
+ | 执行中 API 终止 | `6e5cdd34-35ec-4c8c-9721-0c1fcf137890` | 确认原生 bash 内 Python 已开始 120 秒等待后终止,约 276ms 进入已终止;进程退出,等待后的结果文件未生成,没有推进下一阶段 |
53
+ | 执行中 GUI 终止 | `ae29fac2-4533-4306-902f-dd6b1fcc459c` | 从当前阶段会话标题点击终止,在普通确认弹窗提交;任务已终止、Attempt 已取消、命令进程退出、无延迟结果文件,runner lastError 为空 |
54
+ | 强退、重启与人工恢复 | `e16504a4-b447-4163-94fc-74b963133c34` | 上游已提交、第二阶段命令工作期间 SIGKILL 隔离 Host;重启保持需要处理,不自动重派。核对旧命令退出后在 GUI 确认并只重试第二阶段,最终 GUI 人工终审通过,任务完成 |
55
+
56
+ 重启测试的上游阶段只执行一次,第二阶段保留中断尝试并新增一次成功尝试;有效报告两份,均通过原附件 hash 和交接格式校验。`checkpoint.md` 的 SHA-256 在强退、重启、重试及终审后始终为 `a559a7d2afc1e226a8cdd2070796b7444ac76b13b686d38ba79005bad1872ce3`。新交付文件保留 75% 完成率、未知预算、未上线事实与上游依据,没有“待审/未获批准”等随审核状态过期的标签;通过审核没有改写该文件。
57
+
58
+ 实际测试发现并修复:
59
+
60
+ 1. **编排协议泄漏到阅读界面。** 新回复把交接 JSON 放入保留的 `workflow-handoff` 代码围栏,通过 DSH 官方围栏 HOC 在 Workflow 会话中隐藏;生成的阶段输入通过官方 userText 展示扩展还原为任务输入与反馈。旧无围栏回复默认显示清理后的阶段报告,仍可展开原始会话。持久化记录、核验字节及 hash 均不变。
61
+ 2. **批准后文件仍写“待审”。** 修正创建/修改预置 prompt、阶段执行说明和测试流程定义,由界面管理实时审核状态。流程定义升级保留旧 Task 快照,不批量改写已审核历史产物。
62
+ 3. **网络错误误报成日志完整性错误。** 按已关联的 DSH turn/end 原因区分连接失败、模型错误、中断和不完整输出;无法核验日志时仍保持未知。实际第二次断流已显示 `WORKFLOW_NETWORK_FAILED`,原生重试策略不变。
63
+ 4. **原生确认框阻塞测试与页面。** 终止操作改用现有小 Dialog,并在当前执行阶段标题提供入口;取消、确认及嵌套阶段弹窗交互均验证。正常用户取消不再污染 runner 全局错误。
64
+ 5. **冷启动 Session 所有权不能证明旧命令退出。** SIGKILL 测试实际观察到 macOS 子命令存活,而新 Host 的进程内 jobs 清单为空。恢复后端拒绝无确认的冷启动未知执行核对,界面要求核对旧命令/外部操作已停止再确认;仍在运行的原生会话或作业即使勾选也不能释放。未确认请求不改变任务 revision 或尝试数量。
65
+
66
+ 已完成审核节点保留决定时间及当次绑定的报告,避免审核结束后无报告可看或误用后续成果。断网页面保留原列表并提示当前为上次读取的数据,不能提交执行或审核;网络恢复后提示自动消失。1280px、820px、390px 页面检查均无横向溢出,390px 确认弹窗宽 280px;实际表格字体为 Host 系统字体、13px。
67
+
68
+ 未赶上注入时机的两次先导任务不计入故障通过证据;它们分别完成或终止,记录保留。最终隔离 runner 无运行、无保存收尾、无清理积压、无全局错误,也没有遗留活动作业。
69
+
70
+ ### 发布判断与边界
71
+
72
+ 在 macOS、DSH `0.2.2-rc.3` 的已验证范围内,自动执行、人工打回与批准、产物隔离、断网重试、执行中终止及强退后的人工恢复通过,插件稳定版发布准备检查通过。这里的重启恢复指“保留中断状态,经人工核对后恢复”,不承诺强杀宿主会自动停止所有命令或撤销外部副作用。已有旧文件按原版本保留,人工审核只批准绑定报告,不表示项目目录文件的不可变快照。
73
+
74
+ 尚未进行 Windows/Linux 真机验收,也未以本轮短流程证明任意长任务或所有外部系统的恢复行为。当前内核自身是 rc 版本;插件验收不代表内核获得稳定版保证。故障验收阶段未发布 npm;随后整理为 1.12.0 的功能 PR,合并与发布状态以 GitHub 和 npm 为准。
75
+
76
+ 现有桌面 DSH 已通过插件管理关闭/启用 Kanban 完成重载,没有退出应用。核对运行中模块已包含新的断网分类、operatorConfirmedStopped 校验及参数转交;原有两个验收任务仍为 completed,runner 空闲且无错误。桌面 GUI 确认完成审核节点展示决定时间及当次绑定报告,旧任务仍使用 v1 快照。Host 变更仍需重载插件,单纯刷新前端不足以替换已加载的 Host 模块。
77
+
78
+ ### 1.12.0 文档与国际化收尾
79
+
80
+ 侧边栏入口统一为中文「看板·工作流」和英文「Kanban · Workflow」。中英文 README 并列介绍由人推进的 Kanban 与 AI 执行的 Workflow,补齐英文工作流指南、数据备份说明及响应式流程示意图。两种语言以 GitHub Markdown API 渲染后在本地预览,1280px 与 390px 无页面横向溢出,本地图片和页面锚点正常。旧封面保留在仓库,npm 只包含当前 README 使用的看板截图与流程示意图。
81
+
82
+ UI 按稳定错误码翻译后端失败与恢复提示,不改写历史日志或用户内容;已显示的错误随 Host 语言切换重新翻译。Workflow 日期使用对应界面语言,模型目录继续复用 DSH 的多语言标签。测试核对词条键名及占位符一致、英文词条无中文残留,以及语言切换后失败提示与原始输入的行为。现有桌面端已观察到新入口标题生效。