Repository navigation
refactor(api): move team-run orchestration out of the HTTP handlers (#446) - #523
Merged
Merged
Conversation
… of handlers (#446) Background loops called into HTTP handlers (handlers::teams::advance, reconcile_team_outcomes, fail_team_run_for_execution, worker_launches::*, outputs::deliver_pending) and dispatcher/team_outcomes/team_workflow imported handler types. The code moves verbatim into non-handler modules; only paths and a few visibilities change: - team_runs.rs: TeamDefinition and friends, parse_definition, the repository rules, step starts (start_step_with and its helpers), the run state machine (advance, finalize, fail_team_run_for_execution, reconcile_team_outcomes) and queue-item starts. - launches.rs: launcher calls, launch refresh, terminated-launch handling, launch_profile_internal and stop_launch_internal. - output_delivery.rs: sending (webhook, Slack, Mattermost, Telegram) and the delivery queue. - worker_tokens.rs: IssuedWorkerToken and issue_profile_token. Outside handlers/, only routes.rs, lib.rs and openapi.rs (route documentation) name handlers. No behaviour, status code or OpenAPI change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cks and team steps (#446) The three starts without an HTTP caller each wrote out background_access, Preflight, authorize_access, require_harness_available and require_hourly_quota (team steps also the team-use check). preflight::evaluate_background now runs that sequence once and returns a BackgroundVerdict (Allowed, Denied, Delayed with HarnessUnavailable or HourlyQuota). Each caller keeps its own reaction: a trigger audits and fails on Denied and skips the tick on Delayed, a runtime audits and halts or delays, a team step returns the error. Checks, their order and the errors are unchanged. Request paths (execute, rerun, runtime start) keep using Preflight with the request identity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…446) create_team and replace_team repeated the same 179 lines, from prepare_mode through the stored definition builder. validate_team_request now does that once and returns the definition with the autonomy elevations to audit; the store call and audit entry stay in each handler. Messages, field paths and the order of checks are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mkluiver
added a commit
that referenced
this pull request
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #446. Draft: merge last. Rebase this after the open PRs that touch the moved code; that is less work than rebasing them onto this.
Summary
A refactor with no behaviour change, in three commits. The full workspace tests pass after each one.
509b48ehandlers/intoteam_runs.rs,launches.rs,output_delivery.rsandworker_tokens.rs(verbatim, plus paths andpub(crate)on 9 shared helpers)034a932preflight::evaluate_background→Allowed/Denied/Delayed) for trigger fires, runtime ticks and team steps; each caller keeps its own reaction76a4bf9validate_team_request(the 179 identical lines)Acceptance criteria:
grep -rn "handlers::" crates/orbit-api/srcoutsidehandlers/matches onlyroutes.rs,lib.rsandopenapi.rs.openapi.rshas to name the handlers to document them.Preflightwith the caller's identity; queue starts go throughauthorize_team_runand the team step.No changelog fragment: CONTRIBUTING asks for one only for changes users or operators notice. Docs:
docs/architecture/agent-teams.md("where the code lives") and three paths indocs/security/threat-analysis.md. No bugs were found while moving the code.Testing
cargo fmt --check,clippy --workspace --all-targets -D warnings,cargo test --workspaceon its own database,pnpm api:generate --check(no OpenAPI change),pnpm docs:checkConflicts with open PRs
handlers/teams.rsteam_runs.rs)handlers/teams.rsstart_step_with); itsbackground.rshunks merge clean next to the new preflight matchbackground.rsis_transient()retry goes at the start of theDeniedarm, andlogged(...)goes around the halt and advance writeshandlers/teams.rsvalidate_team_requesthandlers/worker_launches.rslaunches.rs)handlers/outputs.rsoutput_delivery.rs)handlers/teams.rs,handlers/worker_launches.rs🤖 Generated with Claude Code