O4: parallel workers, locks, provider quota #12

Merged
hermes merged 1 commits from o4-parallel into main 2026-11-12 23:52:23 +00:00
Collaborator

Closes #5

  • Worker pool: profile workers = N (default 1); orch pull runs N tasks at once from a shared queue.
  • Locks (flock, <state>/locks, released by the kernel when the holder dies, so no stale locks exist): per task (two orch instances on one queue never run the same task), per repo (worktree creation is serialized), per run (liveness), per provider account slots.
  • Run liveness now uses the run lock instead of the pid, which removes the pid-reuse ceiling from O1.
  • Account concurrency: account (default = profile name; profiles sharing one login set the same name) and max_concurrent (default = workers) cap simultaneous hx runs across all orch processes.
  • Quota: orch reads hx's stream/quota events. A window at or above 99.5 % pauses the account until its reset time; an api 429 / rate-limit failure pauses it for 15 min. The run ends requeued (not failed), the source puts the task back (dir: moved out of .running/), and pull stops handing out work for a paused account. A clean run that saw a full window also pauses the account for the following tasks.
  • Run IDs use milliseconds: a requeued task can start again within the same second and collided on the branch name (found by the flake loop).

Verification: sh tests/all.sh exit 0. New e2e: 5 tasks on 2 workers (max concurrency measured by a +/- log: exactly 2, 5 runs), two profiles on one account with max_concurrent = 1 in two processes (strictly serial), two orch processes on a stateful-claim cmd queue with 6 tasks (each exactly once), quota pause and requeue with resume after the window, pause after a clean run. tests/flake.py: e2e 10/10 idle and 10/10 under 6 CPU hogs.

Not verified against real hx: the quota event shape comes from hx's StreamEvent::Quota serde output (README does not list it), and the 429 text from hx_ai::Error::Api; both are covered with fakes only. Skipped: scheduling by priority, per-repo concurrency cap (repo lock only serializes worktree creation).

Closes #5 - Worker pool: profile `workers = N` (default 1); `orch pull` runs N tasks at once from a shared queue. - Locks (flock, `<state>/locks`, released by the kernel when the holder dies, so no stale locks exist): per task (two orch instances on one queue never run the same task), per repo (worktree creation is serialized), per run (liveness), per provider account slots. - Run liveness now uses the run lock instead of the pid, which removes the pid-reuse ceiling from O1. - Account concurrency: `account` (default = profile name; profiles sharing one login set the same name) and `max_concurrent` (default = workers) cap simultaneous hx runs across all orch processes. - Quota: orch reads hx's `stream/quota` events. A window at or above 99.5 % pauses the account until its reset time; an `api 429` / rate-limit failure pauses it for 15 min. The run ends `requeued` (not failed), the source puts the task back (`dir`: moved out of `.running/`), and `pull` stops handing out work for a paused account. A clean run that saw a full window also pauses the account for the following tasks. - Run IDs use milliseconds: a requeued task can start again within the same second and collided on the branch name (found by the flake loop). Verification: `sh tests/all.sh` exit 0. New e2e: 5 tasks on 2 workers (max concurrency measured by a +/- log: exactly 2, 5 runs), two profiles on one account with `max_concurrent = 1` in two processes (strictly serial), two orch processes on a stateful-claim `cmd` queue with 6 tasks (each exactly once), quota pause and requeue with resume after the window, pause after a clean run. `tests/flake.py`: e2e 10/10 idle and 10/10 under 6 CPU hogs. Not verified against real hx: the `quota` event shape comes from hx's `StreamEvent::Quota` serde output (README does not list it), and the 429 text from `hx_ai::Error::Api`; both are covered with fakes only. Skipped: scheduling by priority, per-repo concurrency cap (repo lock only serializes worktree creation).
hermes added 1 commit 2026-11-12 23:52:18 +00:00
hermes merged commit 06662a085f into main 2026-11-12 23:52:23 +00:00
hermes deleted branch o4-parallel 2026-11-12 23:52:24 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/orch#12