fabro/lib/apps/fabro-server
Bryan Helmkamp 2ca1e1cda0
Serve the Petri run store to workers
The server answers the `/api/v1/runs/{id}/petri/*` endpoints from one
`SqliteRunStore` over its pool. `PetriRuns` in `AppState` keeps the
writer handle each worker opened, keyed by the run and the worker's
owner id, so the lease semantics stay the store's: the handle drops on
the worker's `release`, and every handle of a run drops when the server
observes the run's worker exit, in the subprocess wait path. Never by
timeout. A write from an owner with no held handle reopens only when
the lease row still names that owner, so a server restart or a lost
open reply recovers, and an owner the lease moved away from gets
`petri_stale_owner`.

Every endpoint is worker-scoped through the existing worker auth; a
new `RequireWorkerRunSegment` extractor covers the two-segment routes.
Store errors answer with a machine-readable code, the leased owner and
the conflict position under `meta`, and a backend failure's cause goes
to the server log rather than the worker.

A test drives a held worker through the scheduler, opens the run over
the API with its token, ends the worker, and sees the lease end.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-17 20:12:20 -04:00
..
migrations Run fabro exec through pebble's command-line session 2026-09-11 20:51:01 -06:00
src Serve the Petri run store to workers 2026-09-17 20:12:20 -04:00
tests Carry usage as lithos-llm's Usage and rename billing to usage 2026-09-14 12:31:34 -06:00
build.rs refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
Cargo.toml Serve the Petri run store to workers 2026-09-17 20:12:20 -04:00