2026-07-07 14:55:03 -04:00
|
|
|
---
|
|
|
|
|
kind: task
|
|
|
|
|
slug: shared-schemas-resolve-model
|
|
|
|
|
title: Shared zod schemas and resolveModel() pure function
|
|
|
|
|
plan_slug: automation-foundation
|
|
|
|
|
epic_slug: model-provider-registry
|
2026-07-07 14:56:41 -04:00
|
|
|
status: done
|
2026-07-07 14:55:03 -04:00
|
|
|
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
|
|
|
|
|
|
2026-07-07 14:56:41 -04:00
|
|
|
- [x] Add schemas and types
|
|
|
|
|
- [x] Implement `resolveModel`
|
|
|
|
|
- [x] Add vitest cases (≥6 scenarios)
|
|
|
|
|
- [x] Export from `packages/shared` index
|
2026-07-07 14:55:03 -04:00
|
|
|
|
|
|
|
|
## Estimation
|
|
|
|
|
|
|
|
|
|
S (one agent session)
|
|
|
|
|
|
|
|
|
|
## Acceptance criteria
|
|
|
|
|
|
2026-07-07 14:56:41 -04:00
|
|
|
- [x] `pnpm --filter @tasks/shared test` passes with new tests
|
|
|
|
|
- [x] `pnpm type-check` clean
|
|
|
|
|
- [x] Resolver matches resolution order in ADR § Architecture
|
2026-07-07 14:55:03 -04:00
|
|
|
|
|
|
|
|
## Links
|
|
|
|
|
|
|
|
|
|
- Epic: `./Epic-model-provider-registry.md`
|
|
|
|
|
- Plan: `../Plan-automation-foundation.md`
|
|
|
|
|
- ADR: `../../../docs/adr-model-routing.md`
|