* feat(agent-pool): fundacao read-only do orquestrador (fase A) - docs/plans/agent-pool-orchestrator.md: plano completo (14 secoes) - buildClaimQueue extraido de agent-claim para agent-github (comportamento identico, pinado) - agent-pool-eligibility: isAutonomousClaimable puro e fail-closed + buildPoolQueue - agent-pool-state: parsePoolConfig, marcadores pool-worker, classifyPoolClaim, spawn plan, auto-stop - agent-pool-github: leitura de repo variables (degrada nao-estrito), claims/PRs/migration-lock - pnpm agent:pool -- status|tick --dry-run (inspecao local; live chega na fase B) - 34 specs unit novos (992/992 verde); lint/tsc/knip/cycles/format verdes Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * feat(agent-pool): spawn remoto de workers via Cursor API (fase B) - agent-pool-cursor: client fino da Cloud Agents API v1 (fetch injetavel; CursorApiError com status/body) - agent-pool-models: resolvePoolModel contra /v1/models (id/alias, sufixo -fast -> param, fallback composer-2.5 com warn) - agent-pool-prompt: contrato do worker (claim pre-feito, pula passo 1; PR base stage + Closes #N; promote proibido) - claim coordenado no tick: lock otimista + flip + marcador; agentId idempotente bc-<uuid>; 409 recupera; rollback em falha de spawn - agent:pool workflow --action start|stop|pause|resume|tick|status (variables POOL_*); doctor; wrappers gh workflow run - .github/workflows/agent-pool.yml (dispatch-only; schedule/triggers na fase C) - 19 specs novos (1011/1011); lint/tsc/knip/cycles/format verdes Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * feat(agent-pool): ciclo de vida do supervisor (fase C) - derivePoolClaims com status real dos runs (getCursorRun), heal de spawn via agentId deterministico, cancel de duplicatas - reconcilePoolClaims: falha terminal -> comentario + blocked + archive; merge concluido -> slot livre + archive - auto-stop real: fila drenada + zero ativos -> POOL_ENABLED=false (exclusoes migration-busy nao desligam) - job summary markdown (GITHUB_STEP_SUMMARY) — superficie remota de status - workflow: schedule */10min + pull_request closed em stage (ativam na default branch apos promote) - 2 specs novos (1013/1013); lint/tsc/knip/cycles/format verdes Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * docs(agent-pool): runbook operacional e adendo do spike (fase D) - skill agent-pool: runbook humano (pre-requisitos, start/stop/pause remoto, ciclo de vida, triage, smoke de aceite) - AGENT-OPS: linha na tabela de comandos + secao Agent pool (canal, secrets, ativacao pos-promote) - CHANGELOG-AGENTS: entrada curta da entrega - engineering-audit: pause/resume do pool no protocolo do modo solitario - plano secao 14.1: evidencias do spike 2026-07-30 (environment repo-file confirmado, id bc-<uuid>, degradacao 403, pendencias do primeiro run com CURSOR_API_KEY) Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * fix(test): teardown flake no homeSearchUi.unit.spec (dono do CI) O scheduler do react (prefetch do next/link) podia disparar apos o teardown do jsdom e derrubar o job unit com 'window is not defined' (run 30587862940). afterEach(cleanup) — padrao dos 14 specs irmaos. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
72 lines
2.6 KiB
TypeScript
72 lines
2.6 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { POOL_DEFAULT_MODEL_SLUG, resolvePoolModel } from '../../scripts/lib/agent-pool-models.mjs'
|
|
|
|
const API_MODELS = [
|
|
{ id: 'composer-2.5', aliases: ['composer-latest'], parameters: [{ id: 'fast' }] },
|
|
{ id: 'cursor-grok-4.5-high' },
|
|
{ id: 'kimi-k3-low' },
|
|
]
|
|
|
|
describe('resolvePoolModel', () => {
|
|
it('resolves a declared slug by exact id', () => {
|
|
expect(resolvePoolModel('kimi-k3-low', API_MODELS)).toEqual({
|
|
model: { id: 'kimi-k3-low' },
|
|
requested: 'kimi-k3-low',
|
|
usedFallback: false,
|
|
})
|
|
})
|
|
|
|
it('resolves by alias', () => {
|
|
const result = resolvePoolModel('composer-latest', API_MODELS)
|
|
expect(result.model).toEqual({ id: 'composer-2.5' })
|
|
expect(result.usedFallback).toBe(false)
|
|
})
|
|
|
|
it('maps the repo -fast suffix to the fast param when the table supports it', () => {
|
|
const result = resolvePoolModel('composer-2.5-fast', API_MODELS)
|
|
expect(result.model).toEqual({
|
|
id: 'composer-2.5',
|
|
params: [{ id: 'fast', value: 'true' }],
|
|
})
|
|
expect(result.usedFallback).toBe(false)
|
|
})
|
|
|
|
it('falls back when the base of a -fast slug lacks the fast param', () => {
|
|
const result = resolvePoolModel('kimi-k3-low-fast', API_MODELS)
|
|
expect(result.model).toEqual({ id: POOL_DEFAULT_MODEL_SLUG })
|
|
expect(result.usedFallback).toBe(true)
|
|
expect(result.warn).toContain('kimi-k3-low-fast')
|
|
})
|
|
|
|
it('falls back to composer-2.5 with a warn for unknown slugs', () => {
|
|
const result = resolvePoolModel('modelo-inventado-9', API_MODELS)
|
|
expect(result.model).toEqual({ id: POOL_DEFAULT_MODEL_SLUG })
|
|
expect(result.requested).toBe('modelo-inventado-9')
|
|
expect(result.usedFallback).toBe(true)
|
|
expect(result.warn).toContain('fallback')
|
|
})
|
|
|
|
it('uses the default silently when the issue declares no model', () => {
|
|
for (const absent of [undefined, null, '', ' ']) {
|
|
const result = resolvePoolModel(absent, API_MODELS)
|
|
expect(result.model).toEqual({ id: POOL_DEFAULT_MODEL_SLUG })
|
|
expect(result.usedFallback).toBe(false)
|
|
expect(result.warn).toBeUndefined()
|
|
}
|
|
})
|
|
|
|
it('still resolves when the live table is unavailable (degraded mode)', () => {
|
|
const result = resolvePoolModel('qualquer-coisa', [])
|
|
expect(result.model).toEqual({ id: POOL_DEFAULT_MODEL_SLUG })
|
|
expect(result.warn).toContain('/v1/models')
|
|
})
|
|
|
|
it('ignores non-string frontmatter values', () => {
|
|
const result = resolvePoolModel(42, API_MODELS)
|
|
expect(result.model).toEqual({ id: POOL_DEFAULT_MODEL_SLUG })
|
|
expect(result.usedFallback).toBe(false)
|
|
})
|
|
})
|