# Orch Core Scheduling

## Status

- `completed`

## Owner

- codex

## Started At

- `2026-03-19`

## Goal

- implement the first usable `orch` scheduling slice on top of the existing shared SQLite schema and `inbox` transport
- deliver a leader workflow that can create a run, add tasks and dependencies, dispatch ready work, reconcile inbox state, and answer blocked tasks

## Scope

- add `orch` store primitives for runs, tasks, dependencies, attempts, readiness, dispatch, reconcile, blocked lookup, and run status views
- add CLI commands for the first Milestone 4 surface
- add automated tests for the happy-path scheduler workflow and core state transitions
- update the implementation roadmap with the new progress state

## Checklist

- [x] inspect the current `orch` skeleton, schema, and project roadmaps
- [x] implement `orch` store types and DB operations for runs, tasks, dependencies, attempts, and task-state transitions
- [x] add CLI commands for `run init`, `run show`, `task add`, `dep add`, `ready`, `dispatch`, `reconcile`, `blocked`, `answer`, and `status`
- [x] add automated tests covering run creation, dependency gating, dispatch, blocked-answer flow, and reconcile
- [x] run `go test ./...`
- [x] update `docs/implementation-roadmap.md`
- [x] archive this roadmap with a completion summary when the workstream is complete

## Files

- `docs/roadmaps/active/orch-core-scheduling.md`
- `docs/implementation-roadmap.md`
- `cmd/orch/main.go`
- `internal/cli/orch/root.go`
- `internal/cli/orch/*.go`
- `internal/store/orch.go`
- `internal/cli/orch/*_test.go`

## Decisions

- start with the scheduler loop that reuses existing `inbox` behavior rather than attempting worktree orchestration in the same slice
- keep JSON response style aligned with `inbox` so both CLIs expose consistent machine-readable contracts

## Blockers

- none

## Next Step

- start `Milestone 5: Strict Worktree Support` by extending `orch dispatch` to resolve a concrete base commit and create real worktree metadata

## Completion Summary

- `orch` now has a usable core scheduler loop backed by shared SQLite state and `inbox`
- the implemented CLI surface covers `run init/show`, `task add`, `dep add`, `ready`, `dispatch`, `reconcile`, `blocked`, `answer`, and `status`
- integration tests now verify dispatch/reconcile lifecycle, dependency gating, blocked-question answers, and non-ready dispatch rejection
