- IntakeSession.observe_frame now catches ValueError from crop_to_book
(empty-platform capture), cleans up any orphan wide-image file/dir,
resets the strategy, and does not advance session state. The error
is surfaced via a new last_error field.
- /api/observe adds an "error" field to the response when a capture
fires but fails, instead of an unhandled 500.
- observe_frame only reports fired=True (and only runs capture logic)
when state is WAITING_FRONT or WAITING_BACK, so a completed book
left on the platform can no longer produce a no-op "fired" capture
from an auto-strategy re-triggering.
- observe_frame now holds a per-session threading.Lock for its whole
body, since the frontend polls /api/observe every ~500ms without
chaining requests and Catalogue.update_row() does a non-atomic
read-all-then-rewrite-whole-file rewrite of catalogue.csv.
Adds tests for empty-platform front/back captures and the
BOOK_COMPLETE no-op-fire case, plus an API-level empty-platform test.
Wrap camera.read_frame() call in try/except to catch RuntimeError and
return a 503 Service Unavailable response with structured error JSON
(error + detail fields) instead of letting the exception propagate
as an unhandled 500. This gives kiosk operators a friendly, actionable
error message when the camera becomes unavailable.
Added FailingCamera test fixture and regression test that verifies
the 503 response with expected error details.
- Fix critical resource leak when cv2.VideoCapture.isOpened() returns False:
create capture in local variable, verify it opened, call .release() before
raising RuntimeError, only assign to self._capture after confirming success
- Fix potential leak on repeated open(): release any existing self._capture
before creating a new one
- Add regression test: test_open_raises_when_capture_not_opened now verifies
.release() is called on failed capture
- Add new test: test_open_twice_releases_first_capture verifies first capture's
.release() is called before second is assigned
All 28 tests passing (5 camera + 23 existing).
Implement Catalogue class with BookRecord dataclass for managing the
CSV-based book inventory. Provides operations to append records, read all
rows, update specific books, and generate unique book IDs.
5 tests passing, all functionality working as specified.