|
| 1 | +# Neo.mjs Agent Task Protocol v1.0 |
| 2 | + |
| 3 | +This document defines the strict communication contract ("The Law") for autonomous agents operating within the Neo.mjs ecosystem. It ensures that a swarm of specialized agents (Strategic, Tactical, Execution) can coordinate asynchronously across different repositories without chaos. |
| 4 | + |
| 5 | +## 1. The Philosophy: GitHub as the Bus |
| 6 | + |
| 7 | +We use GitHub Issues as a persistent, asynchronous message bus. |
| 8 | +* **Issues** are Tasks. |
| 9 | +* **Labels** are State. |
| 10 | +* **Comments** are the Audit Trail. |
| 11 | + |
| 12 | +## 2. Label Schema (The State Machine) |
| 13 | + |
| 14 | +Agents MUST respect and enforce these labels. A task can only be in one primary state at a time. |
| 15 | + |
| 16 | +| Label | Meaning | Actor | |
| 17 | +| :--- | :--- | :--- | |
| 18 | +| `agent-task:pending` | The task is defined and queued. Waiting for a worker. | PM / Human | |
| 19 | +| `agent-task:in-progress` | A worker has claimed the task. | Worker Agent | |
| 20 | +| `agent-task:review` | Work is done (PR linked). Waiting for verification. | Worker Agent | |
| 21 | +| `agent-task:blocked` | Agent is stuck/derailed. Needs human intervention. | Worker Agent | |
| 22 | +| `agent-task:completed` | Task is verified and closed. | Human / QA Agent | |
| 23 | + |
| 24 | +### Role Labels |
| 25 | +| Label | Meaning | |
| 26 | +| :--- | :--- | |
| 27 | +| `agent-role:pm` | Strategic/Tactical task (Breakdown, Planning). | |
| 28 | +| `agent-role:dev` | Execution task (Coding, Testing). | |
| 29 | +| `agent-role:qa` | Verification task. | |
| 30 | + |
| 31 | +### Attribute Labels |
| 32 | +| Label | Meaning | |
| 33 | +| :--- | :--- | |
| 34 | +| `ai-generated` | Created by an AI agent (for filtering). | |
| 35 | +| `repo:middleware` | (Optional) Hints that this task belongs to a satellite repo. | |
| 36 | + |
| 37 | +## 3. Issue Templates (The Contract) |
| 38 | + |
| 39 | +Agents MUST parse and generate Issue Bodies using these strict YAML structures. |
| 40 | + |
| 41 | +### A. Epic -> Ticket Handoff (PM to Dev) |
| 42 | +When a PM Agent breaks down an Epic, it creates tickets with this body: |
| 43 | + |
| 44 | +```yaml |
| 45 | +# AGENT TASK CONTRACT |
| 46 | +version: 1.0 |
| 47 | +type: implementation |
| 48 | +role: dev |
| 49 | + |
| 50 | +goal: > |
| 51 | + Implement the "Dark Mode Toggle" in the MainView. |
| 52 | +
|
| 53 | +context: |
| 54 | + epic_issue: 123 |
| 55 | + files: |
| 56 | + - "src/view/Main.mjs" |
| 57 | + - "resources/scss/theme-dark.scss" |
| 58 | + knowledge_base_refs: |
| 59 | + - "learn/guides/styling/Theming.md" |
| 60 | + |
| 61 | +requirements: |
| 62 | + - "Must use CSS variables for colors." |
| 63 | + - "Must persist state to LocalStorage." |
| 64 | + - "Must include a unit test." |
| 65 | +``` |
| 66 | +
|
| 67 | +### B. Ticket -> PR Handoff (Dev to Review) |
| 68 | +When a Dev Agent finishes work, it posts a comment and updates the issue: |
| 69 | +
|
| 70 | +```yaml |
| 71 | +# AGENT RESULT CONTRACT |
| 72 | +status: success |
| 73 | +pr_url: "https://github.com/neomjs/neo/pull/456" |
| 74 | +files_modified: |
| 75 | + - "src/view/Main.mjs" |
| 76 | +test_results: "Passed (3/3)" |
| 77 | +``` |
| 78 | +
|
| 79 | +### C. Derailment Report (Blocked) |
| 80 | +If an agent fails 3 times or hits a critical error: |
| 81 | +
|
| 82 | +```yaml |
| 83 | +# AGENT ERROR REPORT |
| 84 | +status: blocked |
| 85 | +reason: "Test failure loop" |
| 86 | +error_log: | |
| 87 | + Error: Element not found #my-button |
| 88 | + at test/spec/Main.mjs:20 |
| 89 | +attempts: 3 |
| 90 | +request: "Please clarify the selector for the toggle button." |
| 91 | +``` |
| 92 | +
|
| 93 | +## 4. Lifecycle Rules |
| 94 | +
|
| 95 | +### 4.1 Claiming a Task |
| 96 | +1. **Scan:** Agent queries `state:open label:agent-task:pending`. |
| 97 | +2. **Lock:** Agent adds `agent-task:in-progress` and removes `agent-task:pending`. |
| 98 | +3. **Assign:** Agent adds itself (if applicable) or a bot user to "Assignees". |
| 99 | + |
| 100 | +### 4.2 Execution Loop |
| 101 | +1. **Read:** Parse the YAML body. |
| 102 | +2. **Context:** Load the `context.files`. |
| 103 | +3. **Act:** Modify code. |
| 104 | +4. **Verify:** Run tests. |
| 105 | + * *Pass:* Goto Step 5. |
| 106 | + * *Fail:* Retry (max 3 times). |
| 107 | + * *Fail x3:* Label `agent-task:blocked`, post Error Report. Exit. |
| 108 | +5. **Deliver:** Create PR, label `agent-task:review`, post Result Contract. |
| 109 | + |
| 110 | +### 4.3 Cross-Repo Coordination |
| 111 | +For Satellite Repos (e.g., `middleware`): |
| 112 | +* If an agent in `neo` creates a task for `middleware`, it MUST use the `repository` field in the GitHub tool. |
| 113 | +* It SHOULD add a label like `project:middleware` to the original Epic for visibility. |
| 114 | + |
| 115 | +## 5. Safety & Permissions |
| 116 | +* Agents **NEVER** push directly to `main` or `master`. |
| 117 | +* Agents **ALWAYS** create a branch `feat/issue-{id}`. |
| 118 | +* Agents **NEVER** delete files unless explicitly instructed in `requirements`. |
0 commit comments