WIZ-prereq-A Role-keyed dispatch refactor + default type rename #670

Closed
opened 2026-05-01 19:25:47 +00:00 by claude-desktop · 2 comments
Collaborator

User story

As a platform engineer, I want every hardcoded type === "X" check that drives dispatch behaviour replaced with a role-keyed equivalent, AND the default agent type names changed to architect (was foreman) + code-lead (was boss), so that future renames don't break routing and the post-login wizard never has to ask the operator to rename anything.

Acceptance criteria

Role enum

  • apps/server/src/shared/config/agents-config-schema.ts::agentRoleSchema becomes z.enum(["host", "code-lead", "code", "review", "design", "design-review"]). Existing rows missing a role default to a sensible value via a one-time migration (boss → code-lead, foreman → host).
  • Every type in agents.json declares its role. Validation fails on missing.

Refactor sites

  • domain/workflow/post-ci.ts:332MERGE_AGENT_TYPE = "boss"MERGE_ROLE = "code-lead". Resolve via resolveAgentByRole("code-lead").
  • domain/workflow/slash-commands.ts:87resolveAgentByRole("code-lead") for breakdown dispatch.
  • domain/workflow/deps.ts:155-186 — every return { type: "..." } becomes return { role: "..." }. Caller resolves role → instance via wc.typeForRole(role) at the leaf.
  • domain/views/pipeline.ts:60, 74, 79, 92, 289-295 — stage mapping keyed by role.
  • domain/views/board.ts:106 — dispatch label matrix keyed by role.
  • domain/dispatch/completion-proof.ts:277, 284 — proof rules keyed by role.
  • infrastructure/database/db.ts:602, 943, 977role === "host" → host-mode flag.
  • background/janitor.ts:289 — resolve design-reviewer agent via role, not literal name.
  • main.ts:3358 — same.
  • apps/web/src/**/*.{ts,tsx} — display strings + queryKeys updated (["foreman", ...]["architect", ...]). Cache invalidations re-checked.

Default rename

  • config/agents.json — top-level keys foremanarchitect, bosscode-lead. git_author, git_name, git_email updated for both.
  • config/mcp-builtin.json — top-level keys updated.
  • Every /skills/*.md body that names "boss" or "foreman" in prose is rewritten. git grep -E '\bboss\b|\bforeman\b' /skills returns zero hits after the rename.
  • ~/.claude/CLAUDE.md, docs/agents-architecture.md, docs/foreman.md (renamed to docs/architect.md), docs/breakdown.md, every doc page that names agents — rewritten.
  • Migration steps for the operator documented in the PR commit message: create architect + code-lead Forgejo users, mint PATs, add FORGEJO_TOKEN_ARCHITECT + FORGEJO_TOKEN_CODE_LEAD env vars (or seed via /secrets).

Tests

  • Existing dispatch + pool + event-handler tests pass without modification (refactor is mechanical; routing behaviour unchanged).
  • New unit: resolveAgentByRole("code-lead") returns the right agent.
  • New unit: routeForLabels returns { role: "code-lead" } for an architecture-touching ticket.
  • Integration: full dispatch loop on a fixture repo using the renamed types — issue → implement → review → merge with no broken type === "boss" callsites.

Out of scope

  • Rename endpoint (WIZ-prereq-B).
  • Wizard UI (WIZ-1+).

References

  • specs/first-login-wizard.md §Architecture and §Story WIZ-prereq-A
  • ~30 hardcoded sites enumerated in spec §Architecture.
  • apps/server/src/shared/config/agents-config-schema.ts
## User story As a platform engineer, I want every hardcoded `type === "X"` check that drives dispatch behaviour replaced with a role-keyed equivalent, AND the default agent type names changed to `architect` (was foreman) + `code-lead` (was boss), so that future renames don't break routing and the post-login wizard never has to ask the operator to rename anything. ## Acceptance criteria ### Role enum - [ ] `apps/server/src/shared/config/agents-config-schema.ts::agentRoleSchema` becomes `z.enum(["host", "code-lead", "code", "review", "design", "design-review"])`. Existing rows missing a `role` default to a sensible value via a one-time migration (boss → code-lead, foreman → host). - [ ] Every type in `agents.json` declares its `role`. Validation fails on missing. ### Refactor sites - [ ] `domain/workflow/post-ci.ts:332` — `MERGE_AGENT_TYPE = "boss"` → `MERGE_ROLE = "code-lead"`. Resolve via `resolveAgentByRole("code-lead")`. - [ ] `domain/workflow/slash-commands.ts:87` — `resolveAgentByRole("code-lead")` for breakdown dispatch. - [ ] `domain/workflow/deps.ts:155-186` — every `return { type: "..." }` becomes `return { role: "..." }`. Caller resolves role → instance via `wc.typeForRole(role)` at the leaf. - [ ] `domain/views/pipeline.ts:60, 74, 79, 92, 289-295` — stage mapping keyed by role. - [ ] `domain/views/board.ts:106` — dispatch label matrix keyed by role. - [ ] `domain/dispatch/completion-proof.ts:277, 284` — proof rules keyed by role. - [ ] `infrastructure/database/db.ts:602, 943, 977` — `role === "host"` → host-mode flag. - [ ] `background/janitor.ts:289` — resolve design-reviewer agent via role, not literal name. - [ ] `main.ts:3358` — same. - [ ] `apps/web/src/**/*.{ts,tsx}` — display strings + queryKeys updated (`["foreman", ...]` → `["architect", ...]`). Cache invalidations re-checked. ### Default rename - [ ] `config/agents.json` — top-level keys `foreman` → `architect`, `boss` → `code-lead`. `git_author`, `git_name`, `git_email` updated for both. - [ ] `config/mcp-builtin.json` — top-level keys updated. - [ ] Every `/skills/*.md` body that names "boss" or "foreman" in prose is rewritten. `git grep -E '\bboss\b|\bforeman\b' /skills` returns zero hits after the rename. - [ ] `~/.claude/CLAUDE.md`, `docs/agents-architecture.md`, `docs/foreman.md` (renamed to `docs/architect.md`), `docs/breakdown.md`, every doc page that names agents — rewritten. - [ ] Migration steps for the operator documented in the PR commit message: create `architect` + `code-lead` Forgejo users, mint PATs, add `FORGEJO_TOKEN_ARCHITECT` + `FORGEJO_TOKEN_CODE_LEAD` env vars (or seed via `/secrets`). ### Tests - [ ] Existing dispatch + pool + event-handler tests pass without modification (refactor is mechanical; routing behaviour unchanged). - [ ] New unit: `resolveAgentByRole("code-lead")` returns the right agent. - [ ] New unit: `routeForLabels` returns `{ role: "code-lead" }` for an architecture-touching ticket. - [ ] Integration: full dispatch loop on a fixture repo using the renamed types — issue → implement → review → merge with no broken `type === "boss"` callsites. ## Out of scope - Rename endpoint (WIZ-prereq-B). - Wizard UI (WIZ-1+). ## References - `specs/first-login-wizard.md` §Architecture and §Story WIZ-prereq-A - ~30 hardcoded sites enumerated in spec §Architecture. - `apps/server/src/shared/config/agents-config-schema.ts`
Collaborator

🦵 @charles kicked the queue — re-running implement on @boss.

🦵 @charles kicked the queue — re-running implement on @boss.
Collaborator

🦵 @charles kicked the queue — re-running implement on @boss.

🦵 @charles kicked the queue — re-running implement on @boss.
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

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