fix: implement TD-08, remove test sandbox scaffolding from production code

This commit is contained in:
2026-06-12 12:14:30 +02:00
parent 66938c23f2
commit 8d245b3492
3 changed files with 79 additions and 21 deletions

View File

@@ -197,16 +197,10 @@ defmodule BDS.AI.Chat do
}) do
task =
Task.Supervisor.async_nolink(BDS.Tasks.TaskSupervisor, fn ->
receive do
:sandbox_ready -> :ok
end
do_send_chat_message(conversation, user_message, opts)
end)
InFlight.register(conversation.id, task.pid)
:ok = allow_repo_sandbox(task.pid)
send(task.pid, :sandbox_ready)
try do
await_chat_task(task, chat_await_timeout_ms())
@@ -972,20 +966,6 @@ defmodule BDS.AI.Chat do
Repo.one(from project in Project, where: project.is_active == true, select: project.id)
end
defp allow_repo_sandbox(pid) when is_pid(pid) do
if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
try do
Ecto.Adapters.SQL.Sandbox.allow(BDS.Repo, self(), pid)
rescue
_error -> :ok
end
else
:ok
end
:ok
end
defp encode_nullable(nil), do: nil
defp encode_nullable(value), do: Jason.encode!(value)