Submatter/plans/Plan-automation-foundation/Epic-model-provider-registry/Task-shared-schemas-resolve-model.md
Randall Stillwell e256380671 plan(automation): add mission-control foundation backlog and model-routing ADR
Documents the automation foundation plan (nine epics, Epic 1 taskified) and
the accepted model-provider registry contract. Updates .env.example for backlog
import workspace id and local/cloud AI provider env guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 13:55:03 -05:00

65 lines
2 KiB
Markdown

---
kind: task
slug: shared-schemas-resolve-model
title: Shared zod schemas and resolveModel() pure function
plan_slug: automation-foundation
epic_slug: model-provider-registry
status: ready
priority: P1
tenant_id: global
owner: unassigned
cursor_todo_id: null
updated_at: "2026-07-03"
agent_prompt: |
Read docs/adr-model-routing.md first. Implement only packages/shared (and
packages/ai if needed for zero DB imports in shared). No UI, no migration.
claim_task this backlog item before coding; complete_task when done.
---
# Task summary
Add zod schemas and types for model providers, role routes, and a pure `resolveModel()` function per the ADR.
## Description
### Deliverables
1. **`packages/shared`** — export:
- `providerTypeSchema` enum: `anthropic` | `openai` | `google` | `openai_compatible` | `azure_openai`
- `modelProviderSchema`, `roleModelRouteSchema`, `resolvedModelSchema`
- `resolveModel(input)` — pure function; input includes optional brief/convoy overrides, workspace routes, provider catalog
- `PIPELINE_DEFAULT_ROLE_ROUTES` constant (role_id → suggested alias names, not UUIDs)
- `LEGACY_CURSOR_MODEL_ALIASES` map for slug migration
2. **Tests** — `packages/shared/src/model-routing/*.test.ts`:
- Resolution order: brief > convoy > workspace > default
- Missing/disabled alias → structured error
- Legacy slug remapping
### Constraints
- `packages/shared` must not import DB or Node-only APIs.
- Resolver accepts plain objects (tRPC/orchestrator loads rows and passes in).
## Subtasks
- [ ] Add schemas and types
- [ ] Implement `resolveModel`
- [ ] Add vitest cases (≥6 scenarios)
- [ ] Export from `packages/shared` index
## Estimation
S (one agent session)
## Acceptance criteria
- [ ] `pnpm --filter @tasks/shared test` passes with new tests
- [ ] `pnpm type-check` clean
- [ ] Resolver matches resolution order in ADR § Architecture
## Links
- Epic: `./Epic-model-provider-registry.md`
- Plan: `../Plan-automation-foundation.md`
- ADR: `../../../docs/adr-model-routing.md`