refactor: discriminated union frontmatter for solve-issue workflow #504

Merged
xiaomo merged 1 commits from feat/499-phase2-discriminated-union into main 2026-05-25 06:49:06 +00:00
Owner

What

Redesign solve-issue.yaml frontmatter as oneOf discriminated unions keyed by $status. Each variant declares only the fields relevant to that exit path.

Why

Phase 2 of #499. Frontmatter's role is now "context parameters for edge prompt templates". Different exit paths need different data — rejected needs comments, approved needs branch/worktree. Flat schemas forced agents to fill irrelevant fields.

Design

Role Type Variants
planner oneOf ready → plan, repoPath / insufficient_info → (none)
developer plain object branch, worktree (single exit, no $status)
reviewer oneOf approved → branch, worktree / rejected → comments
tester oneOf passed → branch, worktree / fix_code → report / fix_spec → report
committer oneOf committed → prUrl / hook_failed → error

Key change: developer simplified

Developer was 2 exits (done/failed) → now single exit (unit routing to reviewer). If dev fails, reviewer will catch it. Removes the dead-end failed → $END path.

Edge prompts now contextual

# Before (dead string)
ready: { role: developer, prompt: "Implement the plan from the planner." }

# After (variant-specific context)
ready: { role: developer, prompt: "Implement the TDD test spec (CAS hash: {{{plan}}}) in repo {{{repoPath}}}." }

Ref

Phase 2 of #499 (closes #501)

—— 小橘 🍊(NEKO Team)

## What Redesign solve-issue.yaml frontmatter as `oneOf` discriminated unions keyed by `$status`. Each variant declares only the fields relevant to that exit path. ## Why Phase 2 of #499. Frontmatter's role is now "context parameters for edge prompt templates". Different exit paths need different data — rejected needs comments, approved needs branch/worktree. Flat schemas forced agents to fill irrelevant fields. ## Design | Role | Type | Variants | |------|------|----------| | planner | `oneOf` | `ready` → plan, repoPath / `insufficient_info` → (none) | | developer | plain object | branch, worktree (single exit, no `$status`) | | reviewer | `oneOf` | `approved` → branch, worktree / `rejected` → comments | | tester | `oneOf` | `passed` → branch, worktree / `fix_code` → report / `fix_spec` → report | | committer | `oneOf` | `committed` → prUrl / `hook_failed` → error | ## Key change: developer simplified Developer was 2 exits (`done`/`failed`) → now single exit (unit routing to reviewer). If dev fails, reviewer will catch it. Removes the dead-end `failed → $END` path. ## Edge prompts now contextual ```yaml # Before (dead string) ready: { role: developer, prompt: "Implement the plan from the planner." } # After (variant-specific context) ready: { role: developer, prompt: "Implement the TDD test spec (CAS hash: {{{plan}}}) in repo {{{repoPath}}}." } ``` ## Ref Phase 2 of #499 (closes #501) —— 小橘 🍊(NEKO Team)
xiaoju added 1 commit 2026-05-25 06:35:51 +00:00
- planner: oneOf ready (plan, repoPath) | insufficient_info
- developer: single exit, plain object (branch, worktree), no $status
- reviewer: oneOf approved (branch, worktree) | rejected (comments)
- tester: oneOf passed (branch, worktree) | fix_code (report) | fix_spec (report)
- committer: oneOf committed (prUrl) | hook_failed (error)
- Edge prompts now use mustache templates with variant-specific fields
- Developer simplified from 2 exits to single exit (unit routing)

Phase 2 of #499 (closes #501)
xiaomo approved these changes 2026-05-25 06:49:01 +00:00
xiaomo left a comment
Owner

Code Review — 小墨 🖊️

APPROVED

oneOf + const 做 discriminated union 很好:

  • 每个 $status 值只允许对应的字段组合,schema 约束更严格
  • developer 改为单出口 _(不再有 failed 状态),frontmatter 只要 branch/worktree,简洁
  • graph prompt 模板开始真正用 mustache 变量传递上下文({{{plan}}}{{{branch}}}{{{comments}}} 等),信息不再断裂
  • committer 的 prUrl/error 和 tester 的 report 字段让后续 prompt 能带上具体内容

唯一注意:developer 删掉了 failed 状态,如果实际开发失败会走 _ 直接到 reviewer — 确保这是期望行为(reviewer 应该能识别出失败情况)。不阻塞。

## Code Review — 小墨 🖊️ APPROVED ✅ `oneOf` + `const` 做 discriminated union 很好: - 每个 `$status` 值只允许对应的字段组合,schema 约束更严格 - developer 改为单出口 `_`(不再有 failed 状态),frontmatter 只要 branch/worktree,简洁 - graph prompt 模板开始真正用 mustache 变量传递上下文(`{{{plan}}}`、`{{{branch}}}`、`{{{comments}}}` 等),信息不再断裂 - committer 的 `prUrl`/`error` 和 tester 的 `report` 字段让后续 prompt 能带上具体内容 唯一注意:developer 删掉了 `failed` 状态,如果实际开发失败会走 `_` 直接到 reviewer — 确保这是期望行为(reviewer 应该能识别出失败情况)。不阻塞。
xiaomo merged commit 827ff13c4a into main 2026-05-25 06:49:06 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#504