Where the boundaries moved, what was decided and what it costs, what is proven and what is not, and where to look by hand. github.com/povio/lrbo3/pull/75
Before, a backtest was computed inside the request or the chat turn that asked for it. A long one held the process that also answers the health check, the sockets and the job queue: the client saw a 502 and the run left nothing behind. After, a run is on the record the moment it is requested, a job computes it, and on the self-hosted server that computation, from reading the data to the result, happens on a thread of its own.
Not in it: batch runs (a base strategy plus N changes), which are designed only, and making runs faster, which is the next pull request.
| Layer | What is new | Files | Added |
|---|---|---|---|
packages/engine | Both engines tell an optional listener each trading day they finish. Results are unchanged. | 8 | 61 |
packages/record | The run lifecycle: queued, running, succeeded or failed; attempts counted on the run; one compute for futures and options that returns the completed run or the refusal; replays as runs of their own. | 12 | 632 |
packages/agent | run_backtest takes a launcher that can wait for a queued run; a run_progress signal to the browser, outside the audit chain; the export leaves the status out. | 11 | 109 |
apps/robodev-be | The runs/execute job, the one computeRun function, the two ends of a run thread, the wait-by-polling for the assistant, run status in the API. 518 of these lines are the OpenAPI snapshot. | 20 | 995 |
apps/server | The module a run thread loads, which builds that thread's own Postgres pool and storage client; two settings; a test against a real Postgres. | 9 | 254 |
apps/fe | Queued, running and failed runs in Results; live progress in the Run bar and the chat step; polling while a run is pending. 230 of these lines are API tests. | 36 | 498 |
| Docs and rules | ADR-0014, the layout and assistant docs, the vocabulary, the server README, the Robodev API rule. | 9 | 77 |
One function computes every run. The runtime decides only which thread it runs on, never which code runs.
| Decision | Why | What it costs |
|---|---|---|
| The run row is written at the request, and its status lives inside the stored record | A run can no longer vanish, and rows already stored need no migration: one without a status reads as succeeded | Runs cannot be queried by status in SQL without reading the JSON |
| One function computes a run of either kind, and the runtime only decides which thread it runs on | No second mechanism for futures, and the code tested under robodev dev is the code production runs | Under robodev dev and hosted Robodev a run still holds the job's thread while it computes |
The run thread's entry lives in apps/server, which builds the thread's clients | The SDK gives the backend no storage constructor; only the server owns that configuration | bun dev, the API tests' backend and Playwright never exercise the thread; one server test and a boot do |
| A thread per run, not a pool | A run past its limit is stopped outright and its memory goes with the thread | Each run pays the thread's start: loading the runtime and the backend build |
| The assistant waits by reading the run row every 500 ms | Works whichever container claimed the job, holds no thread, and leaves the tool's contract and the audit chain as they were | Up to half a second of added latency per run, and one small query per poll |
| A refusal fails the run at once; any other error is retried, and the third execution fails it | An orphaned or flaky run recovers by itself, and no run is left pending by a dead job | A thread that crashes deterministically is started three times before the run reads as failed |
| No job heartbeat | That is a change to the job runner, outside this ticket | A run whose container went away is executed again only 14 minutes after it started |
ADR-0014 in the pull request holds these with the alternatives that were turned down.
| Claim | Checked against | Result |
|---|---|---|
| A run computed on the thread is the run computed in the caller's thread, byte for byte, for futures and for options | apps/server/tests/runThread.test.ts on a real Postgres: both as returned and as read back from the run row | Pass, both kinds |
| A refusal, a crash and the time limit each end with a failed run and its reason | The same test: dates outside the dataset, a thread whose configuration is broken, a 300 ms limit | Pass; the crash is retried twice first |
| The lifecycle holds: queued before anything is computed, attempts counted, a settled run never rewritten | packages/record/src/runLifecycle.test.ts, 8 cases on the in-memory record | Pass |
| The whole repo still checks | bun check on top of current develop | 31 of 31 tasks |
| The real server computes on the thread | apps/server booted on a throwaway Postgres and driven through the API | Queued, running, succeeded with progress on the row; a refused run failed; the log names the thread |
| Nothing in the browser flows regressed | Playwright on this branch and on a clean develop checkout | 27 passed, 10 failed on both: the same 10 |
| The thread's memory is returned | Process memory around a year of the synthetic options chain | About 80 MB before, 150 to 260 MB peak, back to about 80 to 125 MB after |
Not evidenced: recorded options through the thread (the dataset such a run prepares and saves is covered on the job's thread only; the thread test uses synthetic options). Memory for a year of real options data. The Run bar's and the chat step's live progress in a browser. Hosted Robodev. The 10 Playwright failures are failures on develop too, so those flows have no browser check on either side.
RUN_THREADS=0 on the server computes runs in the job's thread; RUN_THREAD_DB_POOL_MAX (default 2) bounds a thread's connections.Ordered by how much a mistake would cost. Tick them off as you go; the ticks stay in this browser.