Skip to content

[Gastown] PR 12: Refinery Agent #218

@jrf0110

Description

@jrf0110

Parent: #204 | Phase 2: Multi-Agent Orchestration

Revised: The Refinery is now a Kilo CLI process inside the Town Container instead of a cloud-agent-next session. Dispatched by the Rig DO alarm when review queue entries are ready.

Goal

Automated merge review with quality gates. The Refinery is an AI agent (Kilo CLI process) that can reason about test failures and send actionable rework requests.

Flow

When a review queue entry is ready:

  1. Rig DO alarm fires, processReviewQueue() detects pending entry
  2. DO signals container: POST /agents/start with refinery role config
  3. Container spawns a Kilo CLI process (the "Refinery") that:
    • Gets a git worktree with the polecat's branch
    • Runs quality gates (configurable: npm test, npm run build, lint, etc.)
    • If passing → merge to default branch, push, update review queue entry via gt_done
    • If failing → reason about failures, create REWORK_REQUEST mail to the polecat via gt_mail_send, set entry to failed
  4. Refinery process exits after the review completes

Quality Gate Configuration

Stored in rig config:

{
  "refinery": {
    "gates": ["npm test", "npm run build"],
    "auto_merge": true,
    "require_clean_merge": true
  }
}

Refinery System Prompt

The Refinery agent needs a system prompt that:

  • Explains its role (review code, run quality gates, decide merge/rework)
  • Instructs on how to interpret test failures
  • Instructs on writing actionable rework requests (specific, with file/line references)
  • Explains merge mechanics (git merge in the worktree, push to remote)
  • Uses gt_mail_send to communicate rework requests to the polecat

Dependencies

  • PR 1 (Rig DO — review queue)
  • PR 4 (Town Container — process spawning)
  • PR 5 (Rig DO Alarm — processReviewQueue)
  • PR 3 (Tool Plugin — gt_done, gt_mail_send)
  • PR 8 (Manual Merge Flow — review queue entries)

Acceptance Criteria

  • Refinery Kilo CLI process spawned by container on DO alarm signal
  • Quality gate execution (configurable commands)
  • AI-powered failure analysis and actionable rework requests
  • Git merge in worktree and push on success
  • REWORK_REQUEST mail with specific failure details on failure
  • Refinery system prompt
  • Process exits cleanly after review completes

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