|
| 1 | +# Architecture |
| 2 | + |
| 3 | +The **Autopilot Core** operates as an asynchronous, event-driven control plane for automatic code repair and AI operations across the organization's repositories. Rather than integrating deeply into every individual codebase, it utilizes a federated intake model mediated by standard GitHub Issues and GitHub Actions. |
| 4 | + |
| 5 | +## High-Level Workflow |
| 6 | + |
| 7 | +At its core, the architecture relies on a series of decoupled GitHub Actions workflows. A failure in an opted-in repository triggers an issue in `autopilot-core`, which acts as a central queue. An operator then processes this queue and proposes fixes. |
| 8 | + |
| 9 | +```mermaid |
| 10 | +sequenceDiagram |
| 11 | + participant Repo as Opted-in Repository |
| 12 | + participant Core as autopilot-core |
| 13 | + participant Codex as AI / Codex |
| 14 | + |
| 15 | + rect rgb(30, 30, 30) |
| 16 | + Note over Repo,Core: 1. Intake & Triaging |
| 17 | + Repo->>Repo: CI/CD Pipeline Fails |
| 18 | + Repo->>Core: Workflow Run triggers `autopilot-create-issue.yml` |
| 19 | + Core-->>Core: Issue created with labels `autofix + queued` |
| 20 | + end |
| 21 | +
|
| 22 | + rect rgb(30, 45, 60) |
| 23 | + Note over Core,Codex: 2. Operator Execution |
| 24 | + loop Every 5 Minutes (Schedule) |
| 25 | + Core->>Core: `autopilot-operator.yml` scans for `autofix + queued` issues |
| 26 | + alt Issue has `risky` or `needs-design` label |
| 27 | + Core-->>Core: Skip execution |
| 28 | + else Valid Issue |
| 29 | + Core->>Codex: Prompt with issue details and codebase context |
| 30 | + Codex-->>Core: Generate minimal patch/fix |
| 31 | + end |
| 32 | + end |
| 33 | + end |
| 34 | +
|
| 35 | + rect rgb(30, 60, 45) |
| 36 | + Note over Repo,Core: 3. Delivery & Verification |
| 37 | + Core->>Repo: Commit fix to new branch |
| 38 | + Core->>Repo: Open Pull Request |
| 39 | + Repo->>Repo: PR triggers CI/CD validation |
| 40 | + Repo->>Repo: Auto-merge or await human review |
| 41 | + end |
| 42 | +``` |
| 43 | + |
| 44 | +## System Components |
| 45 | + |
| 46 | +1. **Intake Workflows (`autopilot-create-issue.yml`)** |
| 47 | + - Installed via `autopilot-org-installer.yml` into target repositories. |
| 48 | + - Listens for `workflow_run` failure events. |
| 49 | + - Formats the failure context (logs, failing tests) into a structured GitHub issue payload and dispatches it to the `autopilot-core` queue. |
| 50 | + |
| 51 | +2. **Operator (`autopilot-operator.yml`)** |
| 52 | + - Runs periodically on a self-hosted environment (e.g., Windows runner). |
| 53 | + - Polls `autopilot-core` issues. |
| 54 | + - Provides context to the `ci-autopilot` runtime agent. |
| 55 | + - Manages communication with the Codex / AI endpoints to generate a patch. |
| 56 | + |
| 57 | +3. **Installer (`autopilot-org-installer.yml`)** |
| 58 | + - Scans the GitHub organization for repositories containing the `.autopilot/opt-in` marker. |
| 59 | + - Distributes updates to the intake workflows, ensuring standard reporting capabilities without manual setup per repository. |
| 60 | + |
| 61 | +## Design Philosophy |
| 62 | + |
| 63 | +- **Decoupled State**: The queue lives in GitHub Issues. There is no external database, meaning all state transitions are visible and auditable. |
| 64 | +- **Fail-Safe Processing**: The operator acts with least-privilege tokens (`ORG_AUTOPILOT_TOKEN`), ensuring only opted-in codebases can be mutated. |
| 65 | +- **Human-in-the-Loop Fallback**: Pull Requests generated by the system are just like human PRs. They run standard CI and can require mandatory human review if the repository policy dictates. |
0 commit comments