fix: implemented TD-03, InFlight ETS table now owned by a supervised GenServer

This commit is contained in:
2026-06-11 16:59:17 +02:00
parent 9325de2db4
commit 63e35d19e3
4 changed files with 70 additions and 11 deletions

View File

@@ -127,10 +127,20 @@ within the configured budget instead of hanging; dialyzer clean.
---
### TD-03: Fix `BDS.AI.InFlight` ETS ownership and creation race
### TD-03: Fix `BDS.AI.InFlight` ETS ownership and creation race ✅ DONE (2026-06-11)
**Severity: High (correctness).**
**Status: implemented.** `BDS.AI.InFlight` is now a minimal GenServer whose
`init/1` creates the named table (`:named_table, :public, :set,
read_concurrency: true`); it is supervised in `BDS.Application` (before
anything that uses chat), so the table lives for the VM's lifetime and the
concurrent-first-use race is impossible by construction. The lazy `table/0`
creation path is deleted; `register/unregister/lookup` reference the named
table directly. `test/bds/ai/in_flight_test.exs` proves registrations survive
the death of the registering process and that the supervised process owns the
table.
**Context.** `lib/bds/ai/in_flight.ex` creates its named ETS table lazily in
whichever process first calls `table/0`. Two defects: (1) the table is owned
by that first caller — typically a transient LiveView or chat task — so when