feat(routing): hoist webhook-routing hardcoded maps to agents.json #450

Closed
opened 2026-04-27 13:48:47 +00:00 by claude-desktop · 0 comments
Collaborator

User story

As an operator, I want label/author/skill routing rules driven by agents.json per agent type, so that I can rename roles, add new agent types, or change which labels dispatch to which agent without editing apps/server/src/http/webhook-routing.ts.

Why: today LABEL_TO_ROUTE, AUTHOR_TO_REVIEWER, LABEL_TO_REVIEWER, REVIEWER_AGENTS, DESIGN_AGENTS, CODE_FLOW_AGENTS, NON_DISPATCHABLE_TYPES, DEFAULT_REVIEWER_AGENT, SKILL_OVERRIDE_BY_AGENT are all consts in webhook-routing.ts:38-168. Adding "qa" or "translator" requires a code edit + redeploy.

Acceptance criteria

Schema

  • agents.json::types.<TYPE> gains:
    • dispatchable: boolean
    • role: "code" | "review" | "design" | "design-review" | "host"
    • routes_labels: string[] — labels that dispatch issues to this type
    • reviews_authors: string[] — PR authors whose PRs this type reviews
    • reviews_labels: string[] — labels that route review to this type
    • skill_overrides: Record<string, string>event_kind → skill name
  • default_reviewer_type: string added at top level of agents.json
  • Zod schema in shared/config/webhook-config.ts updated; defaults preserve current behaviour

Code

  • LABEL_TO_ROUTE, AUTHOR_TO_REVIEWER, LABEL_TO_REVIEWER, DEFAULT_REVIEWER_AGENT, REVIEWER_AGENTS, DESIGN_AGENTS, CODE_FLOW_AGENTS, NON_DISPATCHABLE_TYPES, SKILL_OVERRIDE_BY_AGENT derived at config-load time from the resolved agents.json (not in source as consts)
  • routeIssueLabel, routeReviewerForAuthor, routeReviewerForLabel etc. take config as parameter (or read from a singleton populated at load); behaviour identical to current hardcoded maps

Tests

  • Existing webhook-routing tests pass with config-driven values
  • New test: changing agents.json (mock) re-routes a label to a different agent type without touching source

Out of scope

  • UI for editing these (Phase 3/4)
  • Renaming any current agent type — keep boss/dev/reviewer/designer/design-reviewer/foreman as default values

References

  • apps/server/src/http/webhook-routing.ts:38-168
  • config/agents.json
  • docs/label-routing.md
  • Audit category 4 (HIGH severity)
## User story As an operator, I want label/author/skill routing rules driven by `agents.json` per agent type, so that I can rename roles, add new agent types, or change which labels dispatch to which agent without editing `apps/server/src/http/webhook-routing.ts`. **Why:** today `LABEL_TO_ROUTE`, `AUTHOR_TO_REVIEWER`, `LABEL_TO_REVIEWER`, `REVIEWER_AGENTS`, `DESIGN_AGENTS`, `CODE_FLOW_AGENTS`, `NON_DISPATCHABLE_TYPES`, `DEFAULT_REVIEWER_AGENT`, `SKILL_OVERRIDE_BY_AGENT` are all `const`s in `webhook-routing.ts:38-168`. Adding "qa" or "translator" requires a code edit + redeploy. ## Acceptance criteria ### Schema - [ ] `agents.json::types.<TYPE>` gains: - `dispatchable: boolean` - `role: "code" | "review" | "design" | "design-review" | "host"` - `routes_labels: string[]` — labels that dispatch issues to this type - `reviews_authors: string[]` — PR authors whose PRs this type reviews - `reviews_labels: string[]` — labels that route review to this type - `skill_overrides: Record<string, string>` — `event_kind` → skill name - [ ] `default_reviewer_type: string` added at top level of `agents.json` - [ ] Zod schema in `shared/config/webhook-config.ts` updated; defaults preserve current behaviour ### Code - [ ] `LABEL_TO_ROUTE`, `AUTHOR_TO_REVIEWER`, `LABEL_TO_REVIEWER`, `DEFAULT_REVIEWER_AGENT`, `REVIEWER_AGENTS`, `DESIGN_AGENTS`, `CODE_FLOW_AGENTS`, `NON_DISPATCHABLE_TYPES`, `SKILL_OVERRIDE_BY_AGENT` derived at config-load time from the resolved `agents.json` (not in source as `const`s) - [ ] `routeIssueLabel`, `routeReviewerForAuthor`, `routeReviewerForLabel` etc. take config as parameter (or read from a singleton populated at load); behaviour identical to current hardcoded maps ### Tests - [ ] Existing webhook-routing tests pass with config-driven values - [ ] New test: changing `agents.json` (mock) re-routes a label to a different agent type without touching source ## Out of scope - UI for editing these (Phase 3/4) - Renaming any current agent type — keep `boss/dev/reviewer/designer/design-reviewer/foreman` as default values ## References - `apps/server/src/http/webhook-routing.ts:38-168` - `config/agents.json` - `docs/label-routing.md` - Audit category 4 (HIGH severity)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#450
No description provided.