Exercise 05: Review and Ship¶
Objective¶
Delegate to the reviewer and git subagents to complete the pipeline.
Delegation Required
This exercise must use the Task tool with the specified subagent_type. Do not write pipeline artifacts manually. The grader cross-references produced_by fields and verifies files exist on disk.
Required Reading
- Reviewing and Testing Code | Cursor Learn -- Code review patterns with agents
- Artifact Schemas -- review-result.json and git-result.json schemas
- Custom Agents | Cursor Docs -- How the
jg-reviewerandjg-gitagents are defined with readonly mode and specific roles
The review-and-ship stage uses the Task tool with subagent_type for jg-reviewer and jg-git.
These map to sequential prompts with appropriate models. The stage-gate validation via check.py is a standalone script that works in any environment.
Context¶
Tests pass (Exercise 04 complete). The pipeline is at the review stage.
Tasks¶
-
Delegate to
jg-reviewerwith this prompt:Read
sandbox/.pipeline/ISSUE-42/plan.jsonandsandbox/.pipeline/ISSUE-42/worker-result.json. Review the diff of changed files insandbox/src/auth/. Writesandbox/.pipeline/ISSUE-42/review-result.jsonwith verdict, blockers, concerns, nits, and"produced_by": "jg-reviewer". -
Delegate to
jg-gitwith this prompt:Create branch
feature/issue-42-auth-middleware. Commit all changes insandbox/with messagefeat(auth): add login endpoint and JWT middleware. Writesandbox/.pipeline/ISSUE-42/git-result.jsonwith branch, commit_sha, commit_message, and"produced_by": "jg-git". -
Run stage-gate validation -- verify the pipeline's stage ordering invariants:
This runspython3 sandbox/.cursor/pipeline/check.py --issue ISSUE-42 --stage reviewcheck.pyto confirm that the review stage's preconditions are met (plan exists, worker completed, test passed before review). -
Verify artifacts:
python3 sandbox/.cursor/pipeline/schema.py --validate sandbox/.pipeline/ISSUE-42/review-result.json python3 sandbox/.cursor/pipeline/schema.py --validate sandbox/.pipeline/ISSUE-42/git-result.json git -C sandbox branch --list 'feature/issue-42*' # branch should exist
Validation
python3 docs/practitioner/tutorials/verify.py --exercise 05
Checks: review-result and git-result exist and pass schema, check.py stage-gate passes, git branch exists.
Part 2: Human-in-the-Loop Approval¶
Production pipelines often require human approval before shipping. The reviewer can output a verdict of blocked_pending_approval when the change is correct but touches sensitive areas (security, database schema, public API) that require explicit human sign-off.
Task¶
Write docs/practitioner/tutorials/outputs/05-hitl-analysis.md with these sections:
- When to block -- List at least 3 categories of changes that should require human approval before the git step runs (e.g., security-sensitive code, breaking API changes, database migrations).
- Approval flow -- Describe what happens when the reviewer outputs
blocked_pending_approval: how does the planner handle it? What information should the approval request contain? Who approves? - Risk without HITL -- What could go wrong if every pipeline ran fully autonomously with no human checkpoints?
Validation¶
python3 docs/practitioner/tutorials/verify.py --exercise 05
Checks (in addition to the Part 1 checks): 05-hitl-analysis.md exists with 3 sections, each with sufficient depth.
Reflection
- What did the reviewer flag? Were the nits reasonable?
- Is the commit message following conventional format?
- What would happen if the reviewer returned blockers?
- How would you configure which types of changes require human approval?
Answer
review-result.json: Should contain verdict: "PASS" (or "PASS_WITH_CONCERNS"), any blockers or concerns found, and produced_by: "jg-reviewer".
git-result.json: Should contain branch, commit_sha, commit_message (conventional commit format), and produced_by: "jg-git".
HITL analysis (outputs/05-hitl-analysis.md) should cover: when to block on human approval (security-sensitive code, DB migrations, breaking API changes), the approval flow (planner pauses, notifies human, waits for signal), and risk without HITL (agents could merge vulnerabilities without human review).