Skip to content

feat: Routing config -- repo-to-agent mapping for webhooks #179

@nexus-marbell

Description

@nexus-marbell

Summary

Implement the routing configuration that maps GitHub repositories to swarm agents. This determines which agent(s) receive notifications when webhook events arrive from a given repository.

RFC: #177 (GitHub Webhook to Swarm Notification Bridge)

Design

New File

  • src/server/webhook_config.py -- parsing, validation, and lookup for routing config

Environment Variable

  • GITHUB_WEBHOOK_ROUTING -- semicolon-delimited repo:agent1,agent2 pairs

Format

repo_full_name:agent_id1,agent_id2;repo_full_name:agent_id3

Examples

# Single repo, multiple agents
GITHUB_WEBHOOK_ROUTING="finml-sage/agent-swarm-protocol:finml-sage,nexus-marbell"

# Multiple repos
GITHUB_WEBHOOK_ROUTING="finml-sage/agent-swarm-protocol:finml-sage,nexus-marbell;finml-sage/real-agent-methodology:finml-sage"

# Wildcard: all repos under an org/user
GITHUB_WEBHOOK_ROUTING="nexus-marbell/*:nexus-marbell;mlops-kelvin/*:kelvin"

Features

  • Multi-repo per agent (an agent can subscribe to many repos)
  • Multi-agent per repo (a repo can notify many agents)
  • Wildcard support: owner/* matches all repos under that owner
  • Specific repo rules take precedence over wildcards
  • Each agent configures their own env to subscribe to repos they care about
  • Parse once at startup, cache the routing table
  • Provide a lookup function: get_agents_for_repo(repo_full_name) -> list[str]

Validation

  • Reject malformed routing strings at startup with clear error messages
  • Warn (log) if a routing entry references an unknown agent ID (agent not in swarm)
  • Empty routing string means no notifications are sent (webhook enabled but unconfigured)

Acceptance Criteria

  • GITHUB_WEBHOOK_ROUTING env var is parsed into a routing table at startup
  • Semicolon-delimited format with repo:agent1,agent2 pairs works correctly
  • Wildcard owner/* matches any repo under that owner
  • Specific repo rules take precedence over wildcard rules
  • get_agents_for_repo() returns correct agent list for a given repo
  • Returns empty list for repos with no routing config
  • Malformed routing strings produce clear error messages at startup
  • Unknown agent IDs produce log warnings (non-fatal)
  • Unit tests cover: single repo, multi-repo, wildcards, precedence, malformed input, empty config

Dependencies

Depends on #178 (webhook receiver endpoint -- provides the framework this config plugs into).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions