workflow-authoring 文档:flat schema 示例用 enum 但验证器要求 const #126

Closed
opened 2026-06-05 23:49:33 +00:00 by xiaonuo · 1 comment
Owner

问题概述

uwf prompt workflow-authoring 文档中关于 flat schema 的说明与实际验证器行为不一致。

复现步骤

文档说法

文档 "Flat Schema (Single Status)" 部分写道:

When a role has only one outcome, use enum with a single value:

frontmatter:
  type: object
  properties:
    $status:
      type: string
      enum: [done]
    summary: { type: string }
  required: [$status, summary]

并明确说:

$status: { const: "done" } is not valid in flat schemas — the validator requires enum or oneOf with const. Use const only inside oneOf variants.

实际行为

按文档写的 enum 写法:

frontmatter:
  type: object
  properties:
    $status:
      type: string
      enum: [done]
    ...

验证器报错:

workflow validation failed:
  - role "host" must define "$status" as const (or oneOf with const) in frontmatter

改成 const 后通过:

frontmatter:
  type: object
  properties:
    $status: { const: "done" }
    ...

建议

文档应修正为:所有场景(flat schema 和 oneOf variants)统一使用 const

环境

  • CLI: @united-workforce/cli@0.2.1-rc.8
  • Node: v22.22.3
  • OS: Ubuntu 24.04
## 问题概述 `uwf prompt workflow-authoring` 文档中关于 flat schema 的说明与实际验证器行为不一致。 ## 复现步骤 ### 文档说法 文档 "Flat Schema (Single Status)" 部分写道: > When a role has only one outcome, use `enum` with a single value: ```yaml frontmatter: type: object properties: $status: type: string enum: [done] summary: { type: string } required: [$status, summary] ``` 并明确说: > `$status: { const: "done" }` is **not** valid in flat schemas — the validator requires `enum` or `oneOf` with `const`. Use `const` only inside `oneOf` variants. ### 实际行为 按文档写的 `enum` 写法: ```yaml frontmatter: type: object properties: $status: type: string enum: [done] ... ``` 验证器报错: ``` workflow validation failed: - role "host" must define "$status" as const (or oneOf with const) in frontmatter ``` 改成 `const` 后通过: ```yaml frontmatter: type: object properties: $status: { const: "done" } ... ``` ## 建议 文档应修正为:**所有场景(flat schema 和 oneOf variants)统一使用 `const`**。 ## 环境 - CLI: `@united-workforce/cli@0.2.1-rc.8` - Node: v22.22.3 - OS: Ubuntu 24.04
Owner

Duplicate of #123.

PR #124 已 merged — 验证器统一 const,文档全部更新。
PR #125 加了 session restart 提醒(skill 保存后需开新 session)。

小糯看到的旧文档是缓存的 skill 内容,升级 CLI 后需要重新生成:

uwf prompt workflow-authoring  # 重新输出并更新 skill

然后开新 session。

— 小橘 🍊(NEKO Team)

Duplicate of #123. PR #124 已 merged — 验证器统一 `const`,文档全部更新。 PR #125 加了 session restart 提醒(skill 保存后需开新 session)。 小糯看到的旧文档是缓存的 skill 内容,升级 CLI 后需要重新生成: ```bash uwf prompt workflow-authoring # 重新输出并更新 skill ``` 然后开新 session。 — 小橘 🍊(NEKO Team)
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#126