Skip to content

fix: pool real de 1000 al motor, Autopilot explica por qué salta un Short y 7 días de gracia de la biblioteca (soporte 7984) - #217

Merged
mutonby merged 3 commits into
mainfrom
worktree-ticket-7984
Nov 26, 2026
Merged

mutonby merged 3 commits into
mainfrom
worktree-ticket-7984

Conversation

@mutonby

@mutonby mutonby commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Tres arreglos que salen de revisar el caso de un cliente (soporte 7984). Cada uno va en su commit y lleva un test que falla en main y pasa con el cambio.

Qué entra

  • 3ac80bb fix(api): pool de 1.000 conexiones de verdad. front_proxy.py pasaba los límites al cliente httpx, que los ignora cuando se le da un transporte propio: el pool real de cada proceso de entrada hacia el motor era de 100. Un solo usuario viendo la vista previa de un vídeo subido lo agotaba y ese proceso devolvía 503 («engine unreachable (PoolTimeout)»): 2.071 veces el 25-nov entre las 07:39 y las 10:38 UTC.
  • 7235d50 fix(autopilot): un vídeo que se salta por ser Short dice por qué. La API añade message a cada ejecución y a POST /api/autopilot/run, y notice en GET /api/autopilot cuando todo lo probado eran Shorts; el panel lo enseña. Al 59 % de quienes prueban Autopilot todas las ejecuciones les salían «youtube_short» sin explicación.
  • cdd47f5 fix(billing): un plan que acaba conserva su biblioteca 7 días más. Los Términos (§13), la política de privacidad y la pestaña History prometen 7 días tras acabar el plan; el código borraba en el primer barrido todo clip con más de 7 días. Solo retrasa borrados, nunca borra antes ni más.

Pruebas

pytest tests/ completo: 2.629 correctos, 105 omitidos, 0 fallos. npm run lint y npm run build correctos. Detalle en el informe del ticket.

Riesgo

Bajo. Cada commit se revierte por separado con git revert.

juancarlos.cavero added 3 commits November 26, 2026 21:20
… meant to be

front_proxy gave its limits to the httpx client, and httpx ignores a
client's limits once it is handed a transport: the pool to the engine was
the default 100 connections per front, not 1000.

A streamed response holds its connection until the client has read it, and
a player that buffers a long source reads slowly on purpose. One viewer
seeking through a long video kept a hundred of them open on one front, and
from then on that front answered every proxied request, the health check
included, with a 503 after the 10 s pool wait ("Front: engine unreachable
(PoolTimeout)"), while the engine and the other fronts were fine.

The limits now go on the transport. The test holds 120 slow streams
against a stand-in engine on a unix socket and asks for one more request:
on the old code only 100 streams reach the engine.
…d for the channel

The channel list cannot tell a Short from a regular video before trying it,
and the latest uploads of a channel that posts through us are our own
shorts, so "clip it" most often lands on one. The answer was a three-word
badge ("already a short"), the activity list showed no reason at all, and a
channel with nothing but Shorts read as Autopilot doing nothing.

- Every run view and the POST /api/autopilot/run answer carry a `message`
  next to the `reason` code (REASON_MESSAGES): what happened and, where
  there is one, the way out.
- GET /api/autopilot sends a `notice` for the whole channel while every run
  so far was skipped as a Short.
- The tab shows the sentence on the click, as the badge's tooltip and in
  the activity list, and the switch says what Autopilot clips instead.

A test walks the module so a new reason gets its sentence.
… Terms say

The Terms (section 13), the privacy policy and the History tab say a paid
library is kept while the subscription is active and deleted 7 days after
it ends. Only accounts that cannot fall back to the free plan got that.
Everyone else read as a plain free account the moment the plan ended, and
the free sweep (every clip older than 7 days) took the whole library on
its next pass: hours after the end, not 7 days.

- metering.plan_ended_at / in_paid_grace: when a subscription row stopped
  granting its plan (the webhook that cancelled it or marked it unpaid,
  never later than the paid period; a checkout that never charged was
  never a plan).
- purge_free_expired skips an account inside that grace, and so does the
  "deleted tomorrow" warning, which would not be true for it.
- The cancel step and the admin alert now state the same rule.

Tests pin the rule with stand-ins and run the real sweep against Postgres
in CI.
@mutonby
mutonby merged commit cc07e6d into main Nov 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant