Repository navigation
refactor(combo): ComboContext + extrai phaseComboSetup (god-file split fase 1) - #4326
Conversation
…file split fase 1) Primeiro incremento da decomposição do god-file combo.ts (2604 LOC). Extrai o bloco de setup do handleComboChat (strategy/relay/resilience/universal-handoff/ context-cache pinning/agent middleware/config cascade/timeout) para phaseComboSetup(ctx), com ComboContext carregando o body mutável compartilhado. - combo/context.ts: ComboContext (carrier do body mutável) + createComboContext. - combo/comboSetup.ts: phaseComboSetup(ctx): ComboSetup (byte-equivalente ao bloco inline; reescreve ctx.body no pin + middleware, retorna os locals derivados). - comboConfig.ts: resolveComboSetupConfig (DRY — encapsula o ternário do config, tipo único p/ ComboContext.config sem cast). - combo.ts: -47 linhas; rebinda os locals do ctx, resto de handleComboChat intacto; remove 6 imports que ficaram órfãos. Comportamento preservado: 357 testes de caracterização combo seguem verdes (+4 novos), integração sse-correctness 5/5, typecheck 0, file-size encolhe (sem _rebaseline). Fases 2-N = sub-planos follow-up. Ver _tasks/quality/2026-06-19-DESIGN-godfiles-decomposition.md.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
✅ Canário VPS (192.168.0.15) — PASSOURodado após o owner liberar RAM na VPS (3.8→7.8Gi). Deploy isolado, prod nunca afetada. Setup: Request real de combo ( Por que isso VALIDA o refactor:
Somado a 361 testes (357 caracterização preservados) + integração sse-correctness 5/5 + typecheck 0, a Parte 4 está validada. Pronto para review/merge. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR #4326 (ComboContext god-file split) added tests/unit/combo/combo-context.test.ts but the unit-runner brace glob had no 'combo' entry, so its 4 tests were orphaned — check:test-discovery flagged a NEW orphan, a second latent red on release/v3.8.30. Add 'combo' to the glob across all lock-step collectors: the 7 package.json test scripts, build-test-impact-map.mjs, check-test-discovery.mjs and the 4 ci.yml run lines. Folded here (rather than a separate PR) because the two release reds are interdependent for Fast-QG: a package.json change triggers the full suite, so a combo-only PR would still trip the bailian red and vice-versa — fixing both in one PR is the only way to land a genuinely green Fast-QG.
…urrent merges (#4335) * fix(providers): bailian-coding-plan static catalog matches registry (10 models) The provider-model sweep (#4324) added qwen3.7-plus, qwen3-coder-plus, qwen3-coder-next and glm-4.7 to the bailian-coding-plan registry entry but left the static fallback mirror in staticModels.ts at the older six, so the static↔registry parity test (bailian-coding-plan-provider.test.ts) went red on release/v3.8.30 whenever TIA selected it. Restore the mirror to all ten models in registry order and align the two legacy count/ID assertions. * chore(test): collect tests/unit/combo/ in the unit runner glob PR #4326 (ComboContext god-file split) added tests/unit/combo/combo-context.test.ts but the unit-runner brace glob had no 'combo' entry, so its 4 tests were orphaned — check:test-discovery flagged a NEW orphan, a second latent red on release/v3.8.30. Add 'combo' to the glob across all lock-step collectors: the 7 package.json test scripts, build-test-impact-map.mjs, check-test-discovery.mjs and the 4 ci.yml run lines. Folded here (rather than a separate PR) because the two release reds are interdependent for Fast-QG: a package.json change triggers the full suite, so a combo-only PR would still trip the bailian red and vice-versa — fixing both in one PR is the only way to land a genuinely green Fast-QG. * chore(db): register apiKeyColumnFallbacks + apiKeyUsageLimitFields as db-internal The api-key usage-limits feature (migration 101) split two helper modules out of src/lib/db/apiKeys.ts — apiKeyColumnFallbacks.ts and apiKeyUsageLimitFields.ts — but did not register them with check:db-rules, so both were flagged as new db/ modules not re-exported by localDb.ts (Hard Rule #2), a third latent red on release/v3.8.30. Both are imported only by db/apiKeys.ts (within src/lib/db/), so they are db-internal: add them to INTENTIONALLY_INTERNAL with that classification (mirrors healthCheck / stateReset) rather than re-exporting internal helpers onto the public localDb surface.
…baseline (#4338) #4326 (ComboContext) introduziu uma violação de complexity: phaseComboSetup media 17 (>15) — a extração moveu os condicionais de pinning/ternários para uma função própria que estourava o teto (irônico para uma decomposição). Extrai o pinning para resolveContextCachePin; phaseComboSetup volta a <15. - comboSetup.ts: helper resolveContextCachePin (server-side context-cache pinning), phaseComboSetup chama-o; remove 'log' órfão do destructure. - complexity-baseline 1890->1895: -1 do fix + drift de features mergeadas após a reconciliação #4330 (#4327 per-key USD quota + outros). Medido no tip 70d89d2. Comportamento preservado: 369/369 testes combo (incl. combo-context), typecheck 0.
…it fase 1) (cheaper-inference#4326) Primeiro incremento da decomposição do god-file combo.ts (2604 LOC). Extrai o bloco de setup do handleComboChat (strategy/relay/resilience/universal-handoff/ context-cache pinning/agent middleware/config cascade/timeout) para phaseComboSetup(ctx), com ComboContext carregando o body mutável compartilhado. - combo/context.ts: ComboContext (carrier do body mutável) + createComboContext. - combo/comboSetup.ts: phaseComboSetup(ctx): ComboSetup (byte-equivalente ao bloco inline; reescreve ctx.body no pin + middleware, retorna os locals derivados). - comboConfig.ts: resolveComboSetupConfig (DRY — encapsula o ternário do config, tipo único p/ ComboContext.config sem cast). - combo.ts: -47 linhas; rebinda os locals do ctx, resto de handleComboChat intacto; remove 6 imports que ficaram órfãos. Comportamento preservado: 357 testes de caracterização combo seguem verdes (+4 novos), integração sse-correctness 5/5, typecheck 0, file-size encolhe (sem _rebaseline). Fases 2-N = sub-planos follow-up. Ver _tasks/quality/2026-06-19-DESIGN-godfiles-decomposition.md.
… lote drift) (cheaper-inference#4336) cheaper-inference#4327 (per-key USD usage quotas), cheaper-inference#4334 (cache-aware compression guard) and cheaper-inference#4326 (phaseComboSetup) added new conditional branches landing after cheaper-inference#4330 measured 1890; the release fast-path doesn't run check:complexity. Measured 1896 on the merged tip.
…urrent merges (cheaper-inference#4335) * fix(providers): bailian-coding-plan static catalog matches registry (10 models) The provider-model sweep (cheaper-inference#4324) added qwen3.7-plus, qwen3-coder-plus, qwen3-coder-next and glm-4.7 to the bailian-coding-plan registry entry but left the static fallback mirror in staticModels.ts at the older six, so the static↔registry parity test (bailian-coding-plan-provider.test.ts) went red on release/v3.8.30 whenever TIA selected it. Restore the mirror to all ten models in registry order and align the two legacy count/ID assertions. * chore(test): collect tests/unit/combo/ in the unit runner glob PR cheaper-inference#4326 (ComboContext god-file split) added tests/unit/combo/combo-context.test.ts but the unit-runner brace glob had no 'combo' entry, so its 4 tests were orphaned — check:test-discovery flagged a NEW orphan, a second latent red on release/v3.8.30. Add 'combo' to the glob across all lock-step collectors: the 7 package.json test scripts, build-test-impact-map.mjs, check-test-discovery.mjs and the 4 ci.yml run lines. Folded here (rather than a separate PR) because the two release reds are interdependent for Fast-QG: a package.json change triggers the full suite, so a combo-only PR would still trip the bailian red and vice-versa — fixing both in one PR is the only way to land a genuinely green Fast-QG. * chore(db): register apiKeyColumnFallbacks + apiKeyUsageLimitFields as db-internal The api-key usage-limits feature (migration 101) split two helper modules out of src/lib/db/apiKeys.ts — apiKeyColumnFallbacks.ts and apiKeyUsageLimitFields.ts — but did not register them with check:db-rules, so both were flagged as new db/ modules not re-exported by localDb.ts (Hard Rule cheaper-inference#2), a third latent red on release/v3.8.30. Both are imported only by db/apiKeys.ts (within src/lib/db/), so they are db-internal: add them to INTENTIONALLY_INTERNAL with that classification (mirrors healthCheck / stateReset) rather than re-exporting internal helpers onto the public localDb surface.
…baseline (cheaper-inference#4338) cheaper-inference#4326 (ComboContext) introduziu uma violação de complexity: phaseComboSetup media 17 (>15) — a extração moveu os condicionais de pinning/ternários para uma função própria que estourava o teto (irônico para uma decomposição). Extrai o pinning para resolveContextCachePin; phaseComboSetup volta a <15. - comboSetup.ts: helper resolveContextCachePin (server-side context-cache pinning), phaseComboSetup chama-o; remove 'log' órfão do destructure. - complexity-baseline 1890->1895: -1 do fix + drift de features mergeadas após a reconciliação cheaper-inference#4330 (cheaper-inference#4327 per-key USD quota + outros). Medido no tip c693acb. Comportamento preservado: 369/369 testes combo (incl. combo-context), typecheck 0.
Contexto
Primeiro incremento da decomposição do god-file
combo.ts(2604 LOC, fora de 2 gates: file-size frozen + mutação excluída). Ver_tasks/quality/2026-06-19-DESIGN-godfiles-decomposition.md.O
handleComboChat(~1600 LOC) tem fases que compartilham locals da "dispatch frontier" — sobretudo obodymutável (reescrito por pinning + middleware). Carregar esse estado numComboContextdeixa cada fase virar uma função pequena, testável e mutável isoladamente. Esta é a primeira fatia (a de menor risco — não captura as closures de dispatch).O que muda
combo/context.ts(novo):ComboContext(carrier dobodymutável compartilhado) +createComboContext.combo/comboSetup.ts(novo):phaseComboSetup(ctx): ComboSetup— extrai o bloco de setup (strategy / context-relay / resilience / universal-handoff / context-cache pinning / agent middleware / config cascade / per-target timeout). Byte-equivalente: reescrevectx.bodyno pin + middleware, retorna os locals derivados.comboConfig.ts:resolveComboSetupConfig(DRY — encapsula o ternário do config; tipo único paraComboContext.config, sem cast).combo.ts:-47 linhas; cria o ctx, chama a fase, rebinda os locals — o resto dohandleComboChatfica intacto. Remove 6 imports que ficaram órfãos.Por que é seguro (behavior-preserving)
combo-context.test.ts) = 361/361.tests/integration/sse-correctness.test.ts→ 5/5 (caminho streaming/SSE do combo preservado).typecheck→ 0 erros.check:file-size→ OK,combo.tsencolhe (sem_rebaseline);comboSetup.ts/context.ts< cap 800.lint→ 3823 = base (zero warnings adicionados).Mudança de hot-path: marco pronto só após canário na VPS
192.168.0.15com tráfego real de combo (streaming + round-robin), confirmando paridade (sem 5xx novos, sem token duplicado, semáforo liberado, pinning OK). Rodando agora.Follow-up
Fases 2-N (buildTargetTimeoutRunner, phaseDispatchRouting, runAttemptLoop, de-dup dos 2 dispatchers, + 8 fases de chatCore) = sub-planos
writing-planspróprios, um PR por fase, cada um atrás de canário. Readicionar cada fase aostryker.conf.jsonmutatecom teste dedicado.🤖 Generated with Claude Code