mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 00:08:25 +00:00
* feat(core): add Redis-backed background chat runs Run AI work once in Celery and follow bounded Redis Streams over HTTP. Keep lifecycle, Stop, leases and final outcomes in Postgres without per-token writes. Include the shared frontend follower, adapter registry, recovery API, migration, queue/deployment wiring and adapter guide. No product uses it yet. Part of #6346 * Remove unused chat run response header exposure * Extract shared async streaming HTTP router * Simplify chat run follower and group engine constants - Check read access once when a stream opens; read run state from Postgres only after 5 s without output or on run.finished. - Split follow_run into small steps around _OutputReader. - Turn event kinds, error codes and stop reasons into StrEnums; the Kuma-only model_unavailable code moves to Kuma. - Document ChatRunType hooks with param, return and raises fields. - Add BASEROW_ASGI_HTTP_MAX_CONCURRENT_STREAMS and size the follower Redis pool by it. - Give handler publish/recover calls their own event loop, so cleanup cannot close pools shared by HTTP followers. - Update ADR 010 and the background chat runs docs. * Clean up chat run interfaces and test setup * Prune chat runs once after 7 days and skip overdue claims - Delete each expired page with one statement. Incomplete runs get one more ensure_interruption_warning call first, and are deleted even if it fails, so run metadata never accumulates. The hook now returns None. - Keep runs for 7 days instead of 30. - Never claim a queued run older than NOT_STARTED_AFTER; the sweeper ends it. * Retry brief Redis failures in chat run followers - A connection error, or a buffer that does not exist yet, is retried with the same cursor, sending heartbeats meanwhile. - run.replay_unavailable is only sent once the follower stops reading, so the browser can treat it as final. * Let finished chat run output expire with the active TTL Nothing reads a buffer once its run has finished: followers return the saved outcome first and recovery only reads running runs. Drop finish() and the 24 h TTL, so a finished buffer expires an hour after its last append. _publish_terminal now reuses _publish. * Run the chat run scale tests on fakeredis Build the buffer's real read and write pools on fakeredis connections, so these tests always run and backend CI needs no Redis service. The Kuma e2e tests cover a real Redis. * Address the remaining chat run review comments - Serialize the saved outcome after the transaction, so only a failed save is logged as one. - Make the primary-pin test transactional; inside the test transaction the router always used the primary, so it could not fail. - Cover the race past the per-user lock, a lost run after Stop and an old writer appending to a recreated buffer. - End the admission test's request with a disconnect, so a regression fails instead of looping. - Document that one worker process runs AI replies one at a time. * Move the chat run migration after develop's core 0130 * Log only the class of an outcome serialization error * Test that the run deadline asks a run to stop * Keep a run's status when a resumed follower rebuilds its output * Note that slow DNS lookups turn off a run's live output