Skip to main content

Module engine

Module engine 

Source
Expand description

Engine — the core orchestration loop.

The engine is the central coordinator. It owns the tick loop, backend connections, channel registry, transport layer, and tmux session manager.

Submodules handle the heavy lifting:

  • tick — core tick phases (session polling, stuck recovery, routing, dispatch)
  • sync — periodic sync operations (cleanup, PR review, mentions, skills)
  • review — PR review pipeline (review agent, auto-merge, change handling)
  • cleanup — worktree cleanup and merged-PR detection

This file contains struct definitions, project initialization, and the main event loop (serve()).

Modules§

auto_merge
PR auto-merge and review-changes handling.
channel_handler
Channel message handlers — routes incoming channel messages to the appropriate action.
cleanup
Worktree cleanup and merged-PR detection.
commands
Owner slash commands — parse, validate, and execute /commands in issue comments.
cooldown
Per-agent and per-model cooldown tracking.
dependencies
Sync GitHub blocked-by links into SQLite and hold tasks until those links are done.
dispatch_guard
RAII guard for the per-task dispatching DashMap.
events
Task event bus — broadcast channel for status transitions.
jobs
Job scheduler — replaces jobs_tick.sh.
priority
relay
Client for orch-relay, which receives the GitHub App’s webhooks on Cloudflare. orch connects out, so it needs no endpoint. The contract is PROTOCOL.md in the orch-relay repository
review
PR review pipeline — review agent orchestration.
review_gate
The CI gate before a review: a review starts only once CI has run on the PR head
review_poll
PR review polling — review_open_prs.
review_shipcheck
Runs shipcheck before a review that has no CI result, so the reviewer’s shipcheck run returns the stored result instead of starting the suite inside the review’s time limit (#3943)
router
Agent router — selects the best agent and model for each task.
runner
Task runner — executes tasks using AI agents.
subscribers
suspend
Host suspend/resume detection.
sync
Sync tick — periodic operations that run less frequently than the core tick.
tasks
tick
Core tick loop phases.

Structs§

EngineConfig
Engine configuration.
ProjectEngine
Per-project engine state.
RunTimeouts
The limit the timeout wrapper puts on one agent run, per complexity

Constants§

RATE_LIMITED_UNTIL_KEY
KV key holding the epoch second the GitHub core window resets, so orch task status can show the limit from a separate process.
RUN_TIMEOUT_GRACE_SECS
Seconds a live session may run past its own timeout before stuck recovery takes it. The timeout wrapper ends the agent at the limit, and the runner still collects the result

Functions§

attribution_footer
Build a standard attribution footer for GitHub comments posted by orch bots.
configured_agents
Return the configured agent list from top-level agents in config.yml, falling back to router::config::DEFAULT_AGENTS when not set.
format_rate_limited_until
Format an epoch second as a local HH:MM:SS for operator-facing output.
orch_footer
Standard Orch attribution footer for issue bodies, PR bodies, and comments.
serve
Start the orch service.