Skip to main content

GitHub Workflow

Hydra uses GitHub labels as its state machine. All pipeline state lives on GitHub — labels, PRs, comments. No in-memory state. If any step is interrupted, the next cron cycle resumes from the current label state.

Label State Machine

┌─────────────────────────────────────┐
│ <trigger-label> │
│ (default: ready-to-build) │
│ (configurable via HYDRA_TRIGGER_LABEL)│
└──────────────┬──────────────────────┘

┌──────────────▼──────────────────────┐
│ pipeline-active + building │
│ (builder container running) │
│ Creates PR, runs quality checks │
└──────────────┬──────────────────────┘

┌──────────────▼──────────────────────┐
│ pipeline-active │
│ + ready-for-code-review (on PR) │
│ + ready-for-security-review (on PR) │
│ (review agents running) │
└──────────────┬──────────────────────┘

┌──────────┴──────────┐
│ │
┌──────▼──────┐ ┌────────▼────────┐
│ verdicts │ │ verdicts │
│ all pass │ │ any fail │
└──────┬──────┘ └────────┬────────┘
│ │
┌──────▼──────┐ ┌────────▼────────┐
│ ready-for- │ │ pipeline-active │
│ review │ │ + building │
│ (or auto- │ │ (fix iteration) │
│ merge if │ │ then re-trigger │
│ yolo) │ │ reviews │
└─────────────┘ └────────┬────────┘

(loops back to review)
max 3 fix iterations
then → needs-input

Label Reference

LabelApplied toMeaningSet byRemoved by
ready-to-build (configurable)IssueNew spec, ready for build. Label name configurable via HYDRA_TRIGGER_LABEL env var (default: ready-to-build).Specter push scriptOrchestrate (build start)
pipeline-activeIssueIn-progress — cron re-dispatches each cycleOrchestrate (build start)Orchestrate (merge or escalation)
buildingIssueContainer actively running — blocks concurrent dispatchOrchestrate (before build/fix)Orchestrate (after build/fix)
ready-for-code-reviewPRCode review agent should runOrchestrate (after build/fix)Supervisor (successful completion)
ready-for-security-reviewPRSecurity review agent should runOrchestrate (after build/fix)Supervisor (successful completion)
ready-for-reviewIssueAll AI reviews passed — human review or auto-mergeOrchestrate (verdicts pass)Human (after merge)
needs-inputIssueEscalated to human — fix budget exhausted or build failureOrchestrateHuman
yoloIssueSkip human review — auto-merge when AI reviews passSpecter push scriptOrchestrate (after merge)
openspecIssueChange is spec-drivenSpecter push script
oversizedIssueSpec generation exceeded turn limit — needs splittingSpecter push scriptHuman

How Cron Reads Labels

cron-hydra.sh (every 5 minutes):

  1. Searches for issues with the trigger label (default: ready-to-build, configurable via HYDRA_TRIGGER_LABEL) OR pipeline-active
  2. Skips issues with building label (another instance working)
  3. Checks hydra.json — skips if dependency issues aren't closed
  4. Dispatches to orchestrate.sh

hydra-supervisor.sh (continuous daemon):

  1. Searches for PRs with ready-for-code-review or ready-for-security-review
  2. Skips if already locked (same PR being reviewed)
  3. Caps at 3 attempts per PR — then removes labels and adds needs-input
  4. Uses shared slot pool (max 5 concurrent with builders)

Concurrency Control

A shared slot pool (/tmp/hydra-slots/) governs all container launches:

  • Max 5 slots across builds, fixes, and reviews
  • cron-hydra.sh and the supervisor's review dispatcher share the same pool
  • building label on GitHub provides distributed locking across multiple Hydra instances
  • If no slots available, work is deferred to the next cron cycle

Board Structure

The project board has four columns:

ColumnWhat lives hereHow cards arrive
TodoIssues with trigger label (default: ready-to-build)Specter creates issue
In ProgressIssues with pipeline-active or buildingOrchestrate moves card
ReviewIssues with ready-for-reviewOrchestrate moves card (all checks pass)
ArchivedMerged changesHuman or yolo merge

Standalone Reviews

Review agents work independently from the build pipeline. Add a label to any PR in the org:

Label on PRWhat happens
ready-for-code-reviewCode Reviewer runs, posts findings + verdict
ready-for-security-reviewSecurity Reviewer runs, posts findings + verdict
Both labelsBoth run sequentially in one slot

Labels are only removed on successful completion. Failed reviews keep labels for retry on next cron cycle (max 3 attempts).

Branch Strategy

  • Spec branches: spec/{slug} (merged to development by Specter, no review needed)
  • Feature branches: feature/{issue-number}/{change-name} (created by builder)
  • PRs target development
  • developmentbetamain via release process

Dependency Enforcement

Each spec includes openspec/changes/{name}/hydra.json:

{ "depends_on": ["core", "access-control-authorisation"] }

Before dispatching a build, the cron verifies all dependencies have closed implementation issues. This enforces build order without burning tokens:

Layer 0: core (no deps) → builds immediately
Layer 1: access-control (core) → builds after core merges
Layer 2: accounts-payable → builds after layer 1 merges
(core + access-control)

Findings

Review agents may discover issues unrelated to the current spec:

  • CRITICAL findings block the PR — must be fixed by builder
  • WARNING findings are posted as comments and may generate separate finding-labelled issues
  • SUGGESTION findings are informational — no action required

Cron Schedule

ScriptIntervalPurpose
cron-hydra.sh*/5 * * * *Discover + dispatch builds, resume active pipelines
hydra-supervisor.shdaemon (1-min watchdog)Run code + security reviews on labelled PRs