Skip to content

F: redraft the current plan through lane D (draft requests, POST /api/plan/drafts) #124

Closed

Description

@mchwang

Problem

A review can get suggestions from Claude (#117), but cannot ask for a whole new plan. E2's prepareDraft can draft the next revision of an existing plan, and the planning provider runs draft mode. But no endpoint, Store lifecycle or E3 path exists for drafts. A plan changes as a whole only by import.

Goal

POST /api/plan/drafts asks Claude for a complete next revision of the review's current plan, from the GitHub issue and optional feedback. The result is kept as a durable request. It becomes the next revision only when the user applies it.

Decided 2026-10-04: redraft the current plan, not create a new task from an issue. A new task from an issue needs task creation outside today's one-review-per-server model, and should start with a design pass.

Work

  1. Store (schema v11, after F: publish a finished task's pull request in production (#103) #110's v10). Add requests.mode ('suggest' | 'draft'; existing rows are suggestions).

    • beginSuggestions takes the mode.
    • completeSuggestions checks the reply by mode. A draft must be a v1 plan at revision n+1 for the plan's issue.
    • getSuggestions returns the mode.
    • A new applyDraft(identity, id, context) imports a ready draft that is still bound to the current revision and snapshot as revision n+1, through the same checks as import, then marks it consumed.
    • applySuggestion refuses a draft, and applyDraft refuses a suggestion.
  2. E3. SuggestionCoordinator.start(input, mode). Draft mode prepares with prepareDraft at revision n+1, and its stale checks compare the base revision. One active planning invocation per plan, shared by both modes.

  3. Server. Recorded routes:

    Suggestion routes refuse draft IDs, and draft routes refuse suggestion IDs.

  4. Docs. The runner-lifecycle planning API table, and planning-acceptance.

Out of scope

  • UI: lane G's planning screen.
  • A first plan for a new task from an issue (see above).
  • Recording a real Claude draft for the draft API. The E4 draft recording already validates through E2.

Acceptance

  • A draft started against revision n and snapshot s is applied as revision n+1. A replayed apply is refused, and a draft made stale by a revision or snapshot change is refused.
  • Draft and suggestion IDs cannot be used on each other's routes.
  • A database at v9 or v10 migrates to v11, and its existing requests read as suggestions.
  • Server tests with a stand-in provider; E4's recorded Claude draft replays through the draft path.

Follows #117. Depends on #110 for the schema version order.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions