Correct the docs the gallery work made wrong

Housekeeping, not new behaviour. The status table still said the WebUI was
"nothing beyond the Vite scaffold" and the server was "Phases 1 and 2" at 194
tests, all of which stopped being true three commits ago. A status table that
is wrong is worse than no status table: it is the first thing read and the last
thing checked.

Endpoint lists in server/README.md were taken from the app's own OpenAPI
schema rather than from memory, which is how the last round of this found that
/ingest was documented as multipart when it is a raw body. The operator half is
now listed separately from the device half, because the two authenticate in
ways that must not be mixed up -- bearer token and no cookies on one side,
session cookie plus CSRF on the other.

Ticked auth-checked image serving, which shipped in 735cbcc, and recorded why
there are two delivery paths and only one authorization path.

The test count is 308 because the suite was run, not because 308 was the number
I remembered.

Two comments in api/app.py contradicted the code beside them. One said the
enroll-secret warning was "not fatal at Phase 1 -- no device endpoint exists
yet", six lines above the device endpoints being mounted; it now says the real
reason the API starts anyway, which is that an enrolled camera keeps working
and refusing to start would take the gallery down too. The other said the
Phase 3 UI endpoints were still to come, directly below the two lines that
mount them.

Left alone deliberately: the "12/12 tests" in docs/reviews/**. Those are
point-in-time review snapshots, and updating them to current numbers would
destroy the only thing they are for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thomas KarnerandClaude Opus 5 committed 2026-09-21 22:01:35 +02:00
1 parent 29c8cf6bfe
commit f9d0b09d2f
4 files changed
+46 -22

No files matched your search

+10 -4
View File
@@ -26,10 +26,10 @@ Anything here that contradicts SPEC means SPEC needs an edit, not a workaround.
| Area | State |
|---|---|
| Firmware | Written, compiles, **never run on hardware**. Known gaps below. |
| Device↔server contract | Specified in full (`firmware/API.md`). Server half of the **device** endpoints implemented (Phase 2); the operator-facing half (firmware upload, device management) waits on user auth in Phase 3. |
| Device↔server contract | Specified in full (`firmware/API.md`). Server half of the **device** endpoints implemented (Phase 2). The operator-facing half (firmware upload, device management) no longer waits on auth — that exists now — only on Phase 4. |
| Data model | Designed (SPEC §3) + §0 additions, migration written and applied, guarded by a drift test. |
| Server | Phases 1 and 2 in [`server/`](server/) — config, schema, health, job queue, scheduler, systemd units, and every device endpoint the firmware calls. Verified on Python 3.14.7 against PostgreSQL 17: 194 tests, migrations applied, real HTTP ingest through the worker to a WebP thumbnail on disk. Not yet on the real host, and **never yet spoken to by real firmware**. |
| WebUI | **Nothing exists** beyond the Vite scaffold on `feature/UI_Basic_implementation`. |
| Server | Phases 1 and 2 plus the Phase 3 server half, in [`server/`](server/) — config, schema, health, job queue, scheduler, systemd units, every device endpoint the firmware calls, and user auth with the captures API behind it. Verified on Python 3.14.7 against PostgreSQL 17: 308 tests, migrations applied, real HTTP ingest through the worker to a WebP thumbnail on disk. Not yet on the real host, and **never yet spoken to by real firmware**. |
| WebUI | Shell, themes, i18n, login and a working cursor-paged gallery on `feature/UI_Basic_implementation`. Devices and System are still honest empty states — they need Phase 4 endpoints. **The gallery's appearance has not been checked in a browser yet.** |
---
@@ -188,7 +188,13 @@ and the System page reads live data through the Vite proxy.
double-submitted. Accounts come from `poorbird user add` — there is no sign-up endpoint.
- [ ] Extend `audit_log` to the *content* mutations (observations, tags, device config) as each
endpoint lands. Auth events are covered; nothing else writes to it yet.
- [ ] **Auth-checked image serving** — the app authorizes, Caddy serves the bytes. An unguessable URL is not access control
- [x] **Auth-checked image serving** — the app authorizes, Caddy serves the bytes via `X-Accel-Redirect`.
An unguessable URL is not access control. One authorization path, two ways of finishing the
response: `serve_images_directly=true` makes the app send the file for development, where there
is no Caddy. Not a separate unauthenticated dev route — that is the kind of thing that survives
into production because it works. `poorbird check` validates the sibling `images`/`thumbs`
layout the handoff depends on, since getting it wrong yields 404s from Caddy with nothing in
the app's log.
- [x] TOTP 2FA — enforced at account creation for `admin` rather than at login, because a
login-time check can lock the only admin out of their own account. Codes required whenever
the account has a secret. Replay inside the ~90s window is documented, not closed.
+28 -10
View File
@@ -1,7 +1,10 @@
# poorBird server
Phases 1 and 2: configuration, schema, health, job queue, scheduler, and every
endpoint the camera calls.
Phases 1 and 2 plus the Phase 3 server half: configuration, schema, health, job
queue, scheduler, every endpoint the camera calls, and user auth with the
gallery's API behind it.
**Device endpoints** — bearer token, no cookies:
```
POST /api/v1/enroll X-Enroll-Secret, returns a bearer token
@@ -14,11 +17,23 @@ GET /api/v1/firmware/{version}.bin OTA image, exact Content-Length
GET /api/v1/health
```
[`../firmware/API.md`](../firmware/API.md) is the contract, and it wins over
anything here: it is what the firmware already does, and the camera is the side
that cannot be patched from a laptop once it is mounted outdoors. The operator
half — firmware *upload*, device management, the gallery — needs user auth and
arrives with Phase 3.
**Operator endpoints** — session cookie + CSRF, never a bearer token:
```
POST /api/v1/auth/login password + TOTP, sets the session cookie
POST /api/v1/auth/logout 204, and the session row is deleted
GET /api/v1/auth/session who am I, or 401
GET /api/v1/captures cursor-paged, filterable
GET /api/v1/captures/{id} detail incl. observations and tags
GET /api/v1/captures/{id}/image authorized, then handed to Caddy
GET /api/v1/captures/{id}/thumb 404 when the thumbnail job has not run
```
[`../firmware/API.md`](../firmware/API.md) is the contract for the device half,
and it wins over anything here: it is what the firmware already does, and the
camera is the side that cannot be patched from a laptop once it is mounted
outdoors. Of the operator half, auth and the gallery exist; firmware *upload*
and device management are Phase 4.
Stack per SPEC §6, deployed natively per [`../TODO.md`](../TODO.md) Phase 1.2:
FastAPI + PostgreSQL 17 + SQLAlchemy 2.0 + Alembic, run as systemd units
@@ -108,7 +123,7 @@ Queue and schema tests need a real PostgreSQL — `FOR UPDATE SKIP LOCKED` has
no equivalent elsewhere, and mocking it would test nothing. They skip
automatically when the database is unreachable, so a green run with no
Postgres proves less than it looks. **Check for `skipped` in the summary**;
a complete run is 12 passed, 0 skipped.
a complete run is 308 passed, 0 skipped.
`test_schema_matches_models.py` creates and drops a `poorbird_schema_check`
database on the same server. It needs a role that may `CREATE DATABASE`.
@@ -124,9 +139,12 @@ src/poorbird/
db.py engine + session factory (sync, deliberately)
models/ SPEC §3 schema + the SPEC §0 additions
images.py JPEG sniffing, atomic writes, thumbnails
api/ FastAPI app, device routes, auth, rate limiting
passwords.py Argon2id — slow on purpose, unlike the device tokens
totp.py 2FA secrets, provisioning URIs, code verification
seed.py synthetic captures, so the gallery has volume to face
api/ FastAPI app, device + operator routes, auth, rate limiting
worker/ queue (SKIP LOCKED), handlers, scheduler
cli.py serve | worker | migrate | check | enqueue
cli.py serve | worker | migrate | check | enqueue | user | seed
migrations/ Alembic
deploy/ systemd units, Caddyfile, env template, INSTALL.md
tests/
+5 -5
View File
@@ -34,8 +34,9 @@ async def lifespan(app: FastAPI):
extra={"version": __version__, "image_root": str(settings.image_root)},
)
if not settings.enroll_secret_is_set:
# Not fatal at Phase 1 -- no device endpoint exists yet -- but it will
# be the first thing to break in Phase 2.
# A warning rather than a refusal to start: an existing camera keeps
# working with the token it already holds, and taking the whole API
# down would also take down the gallery. Only enrollment breaks.
log.warning("POORBIRD_ENROLL_SECRET is not set; device enrollment will refuse requests")
yield
log.info("poorbird api stopping")
@@ -75,9 +76,8 @@ def create_app() -> FastAPI:
app.include_router(firmware.router, prefix=API_PREFIX)
# The device contract (firmware/API.md) is complete apart from /stream,
# which is Phase 6. Still to come: the admin-facing POST /firmware, which
# needs user auth, and the Phase 3 UI endpoints.
# Phase 3 mounts the UI endpoints.
# which is Phase 6. Still to come on the operator side: the admin-facing
# POST /firmware and device management, both Phase 4.
return app
+3 -3
View File
@@ -1,8 +1,8 @@
# poorBird web
Phase 3 scaffolding: shell, themes, i18n and the auth plumbing. Built on the
dev machine and shipped to the server as static files — nothing here runs on
the server (SPEC §6).
Phase 3: shell, themes, i18n, login and the gallery. Built on the dev machine
and shipped to the server as static files — nothing here runs on the server
(SPEC §6).
```bash
cd web