spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

[Feature]: surface gate detail in the workflow run/resume --json outcome

Open doquanghuy opened this issue 5 months ago • 1 comments

Problem Statement

The machine-readable outcome of workflow run/resume (--json) is {run_id, workflow_id, status, current_step_id, current_step_index}. When a run pauses at a gate, that payload is indistinguishable from any other pause — and the gate's message, options, and (after an interactive choice) choice exist only in the gate step's internal output (steps/gate/__init__.py stores them, including output.choice), never in the structured outcome. An orchestrator driving Spec Kit programmatically has to parse the human-facing stdout to learn "this is a review gate, here are the options".

Proposed Solution

Two small pieces (this is an API-surface proposal — would appreciate direction before polishing):

  1. Record each step's type in the run state's step results (one line in the engine's step_data).
  2. When the run sits at a gate, add a gate block to the --json payload:
{
  "status": "paused",
  "current_step_id": "review",
  "gate": {
    "step_id": "review",
    "message": "Approve the thing?",
    "options": ["approve", "reject"],
    "choice": null
  }
}

choice populates when the outcome ends at the gate with a decision recorded — e.g. an interactive rejection with on_reject: abort yields a failed payload whose gate block carries "choice": "reject", and an on_reject: retry pause carries the rejected choice. (A mid-flow approval proceeds past the gate, so the final payload has no gate block — by design.) Non-gate runs and runs that end elsewhere are unchanged (no gate key).

I have a small reference PR ready.

Alternatives Considered

  • A generic paused_step: {id, type, output} block (more information, larger surface, leaks step internals).
  • A dedicated gate-outcome status value (changes the status enum — more disruptive than an additive block).
  • Status quo: orchestrators parse stdout (fragile, and impossible under --json where the stream is redirected).

Component

Workflow engine / CLI (--json outcome)

AI Agent (if applicable)

n/a

Use Cases

  • External orchestrators (CI, parent-pipeline coordinators) detecting "human review needed" and presenting the gate's options without scraping terminal output.
  • Distinguishing a review-gate pause from other waiting states programmatically.

AI disclosure (per CONTRIBUTING.md): this issue and the accompanying reference PR were authored with AI assistance (Claude); verified by running the repo's test suite locally.

doquanghuy avatar Jun 12 '26 17:06 doquanghuy

This shipped in #2965 (merged 2026-06-22). Verified on current main: the run/resume --json payload includes the gate block via _gate_outcome in src/specify_cli/workflows/_commands.py (step id, message, options). The PR did not carry a Fixes #2964 line, so the issue stayed open. Looks safe to close.

marcelsafin avatar Jul 08 '26 20:07 marcelsafin