- Add GNS-2 label taxonomy (66 labels) with semantic routing - Tier 2 agents (capability-analyst, agent-architect, evaluator) enabled for self-cascade - GNS agent protocol: checkpoint v2 in issue body, machine-readable event footers - GiteaClient extended: checkpoint CRUD, event parsing, assignee/lock control, triggered issue polling - PipelineRunner rewritten as PollingSupervisor: reactive instead of active dispatch - Security: circuit breakers (is_locked), budget governance, depth limits - Scripts: init-gns-labels.py, validate-gns-agents.py - Milestone #67 + 7 phase issues (#99-#105) tracking evolution Refs: Milestone #67, Issues #99-#105
4.8 KiB
4.8 KiB
GNS-2 Agent Protocol
Rules for all agents participating in the Gitea-Nervous-System v2.0 distributed workflow.
Core Principle
Gitea is the shared brain. Every agent reads state from Gitea on entry and writes state back on exit. No agent holds exclusive state in RAM.
Entry Protocol
Every agent MUST execute on entry:
- Read Issue:
GET /repos/{owner}/{repo}/issues/{number} - Parse Checkpoint: Extract YAML block from issue body
- Check Budget: Verify
checkpoint.budget.remaining > estimated_cost - Check Depth: Verify
checkpoint.depth < max_depthfrom cascade label - Read Timeline:
GET /issues/{number}/timelinefor recent events - Read Comments:
GET /issues/{number}/commentsfor agent messages
Execution Protocol
During work:
- Atomic Tasks: One clear deliverable per invocation
- Token Budget: Stop and report if approaching limit
- Subagent Calls (Tier 2+ only): Check budget and depth before spawning
- State Changes: Update labels, assignee, milestone via API
Exit Protocol
Every agent MUST execute before terminating:
- Write Result Comment: Structured markdown with machine-readable footer
- Update Checkpoint: Patch issue body with new checkpoint YAML
- Update Labels: Reflect new phase, quality, budget state
- Set Assignee: Hand off to next agent or self
- Log Cascade: If subagents were spawned, include cascade table
Comment Format
## 🔄 {agent-name} | phase:{phase} | depth:{depth}
**Event Type**: {subagent_result|state_change|budget_update|security_alert|checkpoint}
**Parent**: {parent_invocation_id}
**Invocation**: {invocation_id}
**Budget**: {before} → {consumed} → {remaining}
### Action Taken
{description}
### Result
```json
{result_json}
Next Decision
Recommended next: @{agent-name} Rationale: {why} Estimated tokens: {number} Budget remaining: {number}
Cascade Log (if any)
| Agent | Task | Result | Tokens | Verdict |
|---|---|---|---|---|
| {agent} | {task} | {result} | {tokens} | ✅/❌ |
State Changes
- Labels add: {list}
- Labels remove: {list}
- Assignee: {name}
- Milestone: {id}
## Machine-Readable Footer
```html
<!-- GNS_EVENT: {
"type": "subagent_result|state_change|budget_update|security_alert|checkpoint",
"agent": "agent-name",
"invocation_id": "cap-042-003",
"parent_id": "orch-042-001",
"depth": 1,
"budget": {"before": 5000, "consumed": 1200, "remaining": 3800},
"state_changes": {
"labels_add": ["phase::drafting-spec"],
"labels_remove": ["phase::gathering-evidence"],
"assignee": "agent-architect",
"milestone": null,
"is_locked": false
},
"cascade_log": [
{"agent": "history-miner", "task": "git search", "tokens": 1200, "verdict": "pass"}
],
"next_agent": "agent-architect",
"estimated_next_tokens": 3000,
"timestamp": "2026-05-08T20:00:00Z"
} -->
Checkpoint Schema v2
checkpoint:
version: 2
issue: {number}
phase: {phase_name}
depth: {current_depth}
last_agent: {agent_name}
last_invocation: {invocation_id}
budget:
total: {allocated}
consumed: {used}
remaining: {left}
state:
labels: [{list}]
assignee: {agent_name}
milestone: {milestone_id}
history:
- {agent: name, invocation: id, action: description}
next_agent: {agent_name}
next_estimated_tokens: {number}
created_at: {ISO8601}
Budget Governance
- Agent MUST check
checkpoint.budget.remainingbefore any subagent call - Subagent call rejected if
estimated_cost > remaining * 0.5 - Budget exhaustion → add label
budget::exhausted, pause, request human approval - Agent MUST update
consumedandremainingin checkpoint after completion
Depth Governance
cascade::depth-0: Leaf agents, no subagent callscascade::depth-1: One level of subagent callscascade::depth-2: Two levels of subagent callscascade::depth-n: Unlimited (orchestrator only)- Depth exceeded → add label
cascade::depth-exceeded, lock issue
Security Rules
- Agent MUST NOT modify
.kilo/files withoutpermission::evolve-system - Agent MUST NOT call subagents not in
allowed_subagentslist - Agent MUST NOT exceed
max_cascade_depth - Violation → add label
permission::violation,is_locked = true
Recovery
If agent crashes or orchestrator restarts:
- Read issue body → parse checkpoint
- Read timeline → reconstruct events since last checkpoint
- Read comments → parse GNS_EVENT footers
- Resume from
next_agentin checkpoint - No state lost — everything is in Gitea
Prohibited Actions
- DO NOT hold state in RAM without writing to Gitea
- DO NOT skip comment footer
- DO NOT skip checkpoint update
- DO NOT exceed budget or depth limits
- DO NOT modify checkpoint version
- DO NOT hardcode APAW in API calls