fix(command-goal): report corrupt goal state from /goal
The command mapped every GoalError to the generic invalid-command text, so GOAL_STATE_CORRUPT lost its replay diagnostic. It now rethrows that code so the command runtime reports the cause. Refs #7869
This commit is contained in:
1 parent
5a8dc54372
commit
d5a2bd2b8b
5 files changed
+14
-6
No files matched your search
@@ -33,8 +33,8 @@
|
||||
en: 7fba8a13f8452dc1
|
||||
zh: bbaba056cda78ec9
|
||||
/deepseek-ai-dsh-command-goal/understand-the-implementation/design:
|
||||
en: ab637815b21bf065
|
||||
zh: 56eb4ae2ad368994
|
||||
en: 47880a3aa7c982a2
|
||||
zh: eed5b31970e01a51
|
||||
/deepseek-ai-dsh-command-goal/understand-the-implementation/source-map:
|
||||
en: a34756578cce7cc4
|
||||
zh: 61079561a2bf742d
|
||||
|
||||
@@ -76,7 +76,7 @@ This section explains how the command parses input and renders output; the obser
|
||||
### Design
|
||||
|
||||
- **Grammar, not free text.** The parser recognizes only the exact control words (`clear`, `pause`, `resume`, `edit`) when they fill the whole input; every other non-empty suffix is an objective. `edit` alone is invalid, and `edit` refuses to replace an unfinished goal directly.
|
||||
- **Domain rejections become stable errors.** `GoalError` outcomes are converted into direct command errors with a fixed message; unexpected failures rethrow so adapters report a command failure rather than a domain result. Rendered output never exposes branded ids or revisions.
|
||||
- **Domain rejections become stable errors.** `GoalError` outcomes other than `GOAL_STATE_CORRUPT` are converted into direct command errors with a fixed message; corrupt goal state and unexpected failures rethrow so adapters report a command failure rather than a domain result. Rendered output never exposes branded ids or revisions.
|
||||
- **Attachments accompany the objective.** On a successful create or edit, the command submits one user followup carrying the admitted image and file blocks in selection order plus the fixed text `Reference attachments for the goal objective.` Every other path submits nothing, so the dispatching composer keeps the draft and cards.
|
||||
|
||||
### Source map
|
||||
|
||||
@@ -76,7 +76,7 @@ kind: "package-reference"
|
||||
### 设计
|
||||
|
||||
- **语法,而非自由文本。** 解析器只在控制词(`clear`、`pause`、`resume`、`edit`)填满整个输入时识别它们;其他任何非空后缀都是目标。单独的 `edit` 无效,且 `edit` 拒绝直接替换未完成的 goal。
|
||||
- **领域拒绝变成稳定错误。** `GoalError` 结果会转换为带固定消息的直接命令错误;意外失败会重新抛出,使适配器报告命令失败而非领域结果。渲染输出绝不暴露带品牌类型的 id 或 revision。
|
||||
- **领域拒绝变成稳定错误。** 除 `GOAL_STATE_CORRUPT` 外的 `GoalError` 结果会转换为带固定消息的直接命令错误;goal 状态损坏与意外失败会重新抛出,使适配器报告命令失败而非领域结果。渲染输出绝不暴露带品牌类型的 id 或 revision。
|
||||
- **附件随目标提交。** create 或 edit 成功时,命令提交一条用户 followup 消息,按选择顺序携带已准入的图片块与文件块,再附加固定文本 `Reference attachments for the goal objective.`。其他路径不提交消息,因此分发方 composer 保留草稿和附件卡。
|
||||
|
||||
### 源码地图
|
||||
|
||||
@@ -176,7 +176,8 @@ function executeGoalCommand(ctx: Context, invocation: CommandInvocation): Comman
|
||||
default: return assertNever(command, 'goal command')
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof GoalError) {
|
||||
// Corrupt goal state is not a command-shape problem; the command runtime reports its cause.
|
||||
if (error instanceof GoalError && error.code !== 'GOAL_STATE_CORRUPT') {
|
||||
return {
|
||||
kind: 'error',
|
||||
text: 'The goal command is not valid for the current state. Run /goal to view available commands.',
|
||||
|
||||
@@ -5,7 +5,7 @@ import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||
import type { Agent, AgentStatus } from '@deepseek-ai/dsh-agent'
|
||||
import CommandRuntime from '@deepseek-ai/dsh-commands'
|
||||
import GoalService from '@deepseek-ai/dsh-goal'
|
||||
import type { GoalRef } from '@deepseek-ai/dsh-goal'
|
||||
import { GoalError, type GoalRef } from '@deepseek-ai/dsh-goal'
|
||||
import SessionStore, { Session, SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
|
||||
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
||||
import * as commandGoal from '@deepseek-ai/dsh-command-goal'
|
||||
@@ -237,6 +237,13 @@ describe('/goal human command', () => {
|
||||
vi.spyOn(test.ctx.goals, 'get').mockImplementationOnce(() => { throw new Error('unexpected failure') })
|
||||
await expect(run(test)).rejects.toThrow('unexpected failure')
|
||||
})
|
||||
|
||||
it('reports corrupt goal state instead of the generic invalid-command result', async () => {
|
||||
const test = await harness()
|
||||
const corrupt = new GoalError('goal replay failed at session event 3: invalid goal stream', 'GOAL_STATE_CORRUPT')
|
||||
vi.spyOn(test.ctx.goals, 'get').mockImplementationOnce(() => { throw corrupt })
|
||||
await expect(run(test)).rejects.toBe(corrupt)
|
||||
})
|
||||
})
|
||||
|
||||
describe('/goal attachments', () => {
|
||||
|
||||
Reference in new issue
Block a user