forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on af331ecc8a4a0c661bcdbc905b95bb2cf77a72deFiltered to src/error.rsClear filter

2026-09-12

2026-09-07

✨ feat: real /health, error and panic telemetryAhmet Kaan Gümüş · c00f83a
✨ feat: real /health, error and panic telemetry

`/health` (and its `/` mirror) now answers what the process can actually do —
`{status, db, ai:{enabled,workers}}`, 200 when the database is up and 503 with
`"db":"down"` when it is not. It is exempt from the db guard alongside
`/limits`: a probe refused by the outage it exists to report names nothing.

Every `AppError` arm now records a stable snake_case class on the request span
(`error.type`) and counts itself into `errors_total` with that class and the
status. One log line per refusal, by severity: 5xx at error! with the
underlying error (which the arm's own Display hides), 429 and the reconnect
503 at warn!, the caller's 4xx at debug! — no path, no user, no body anywhere.
`record_response` no longer overwrites `error.type` with the status code.

Panics are no longer a dropped connection: a process-wide hook logs
`exception.type/message/stacktrace` and counts `panics_total`, and a
`CatchPanicLayer` inside the trace layer answers the same `{"error":"internal
server error"}` 500 every other internal error answers, tagging its span
`panic`.

Claude-Session: https://claude.ai/code/session_018sqvyBCZ9kpQP6vnGomT2s

2026-09-05

✨ feat: builder sells modules per school, one at a time or in batchesAhmet Kaan Gümüş · c78e41a
✨ feat: builder sells modules per school, one at a time or in batches

`GET|PATCH /schools/{slug}/modules`, `POST|DELETE /schools/{slug}/modules/{module}`;
a batch names modules or whole packages, resolves to one set, is validated
against the dependency graph once and written once, or not at all. Public
`GET /modules/catalog` lists modules, packages and requirements; a school
reads its own set at `GET /modules`. Schools can be created with a narrowed
set.
✨ feat: per-school modules; a disabled module answers 403 on every route in its nestAhmet Kaan Gümüş · 5d7f87c
✨ feat: per-school modules; a disabled module answers 403 on every route in its nest

Twenty-one modules, one per router nest, with an explicit dependency graph
derived from the record links (exams need courses and subjects, marks need
exams, …) and four packages for the catalog. The enabled set lives on the
school's control row and rides the tenant resolution that already happens
once per request; every nest carries a route_layer gate, the four child
creates inside /courses are gated by their own module, and the AI blob
stream refuses `module_disabled` when course notes are off.

2026-08-04

feat: 🏷️ answer a manual class refusal with the pump's own codeAhmet Kaan Gümüş · 574b977
feat: 🏷️ answer a manual class refusal with the pump's own code

Attaching a course or adding a member by hand refused with an English
sentence, while the very same conditions reached through a blueprint
pump had just become machine codes. One cause, two shapes — and the
client that has to word them is bilingual.

The vocabulary now has one home on the pump's own refusal type, the
blueprint's skip list reads it from there, and the two manual routes
carry it as a code beside the sentence they already sent. Prose is
unchanged and no other route gains the field.

Coding these also exposed a claim this series had been making wrongly:
a pump attaches a course it has just proved alive, so it can never
report a stale link. Only a member add walks the section's existing
courses, and only it can answer that one.

2026-07-22

2026-07-21

🐛 fix(db): retry boot connect, refuse while socket downAhmet Kaan Gümüş · bebca49
🐛 fix(db): retry boot connect, refuse while socket down

Two failures survived 6627128, which only classified errors from queries
in flight *at* the drop — queries arriving after it produce no error at
all, so there was nothing to classify.

Boot did one connect() and exited on refusal. The runtime then restarted
the process, it failed again in ~100ms, and a few seconds of startup skew
burned the whole restart budget: 6 deaths in 0.6s in the field log, then
down for 12h. Now retries 1s doubling to 5s, forever — only the dial,
since bad credentials never heal by waiting.

A query issued while the socket is down does not fail. The SDK's
router_reconnect loops on 1s retries and stops draining route_rx, so the
query parks until the database returns and only then executes. Reproduced:
POST /auth/login gave no response at 25s, and the keepalive went silent
4m17s before firing two pings in the same millisecond on heal.

Those two pings rule out a plain timeout middleware — a parked query still
runs, so a timeout-sourced 503 would let a client retry double-apply a
mark or an exam answer. Instead the keepalive (now 5s) publishes DbHealth
and db_guard refuses at the edge, before anything is queued, which is what
keeps Retry-After: 1 honest. The 30s request timeout is only a backstop
for requests racing detection; those answer DbTimeout — same 503, no
Retry-After, "may or may not have applied". WS and SSE are unaffected:
both return their response immediately and stream afterwards.

Known gap: exam_ws socket-loop queries run after the upgrade response, so
db_guard does not cover them; they still park and heal on reconnect.

Verified in podman against the existing volume: boot with the database
down backs off and stays alive, requests during an outage answer 503 in
0.3ms, recovery needs no restart.
🐛 fix(db): map ws session-replay races to 503 + keepaliveAhmet Kaan Gümüş · 6627128
🐛 fix(db): map ws session-replay races to 503 + keepalive

The SDK's reconnect replays signin/use_ns fire-and-forget, so queued
queries can race it and get refused pre-execution ("Specify a
namespace" / "Anonymous access"), and a query in flight at the drop
dies as a connection error — all surfaced as 500s. Classify those
(narrow strings + is_connection) as DbUnavailable → 503 with
Retry-After: 1; refused-pre-execution makes a client retry always
safe, unlike a body-replaying retry middleware. A 30s RETURN 1
keepalive task makes drops heal between requests, not under one.
Restart storm (2× DB restarts under 200ms hammer): 0×500.

2026-07-15

✨ feat(notes): file attachments with school-set size capAhmet Kaan Gümüş · f1b532b
✨ feat(notes): file attachments with school-set size cap

Blobs live on disk under FILES_PATH (same volume as the DB), named by
the row's ULID so user input never shapes a path; the note_file row
keeps only metadata. DB-blob storage rejected: multi-MB PDFs bloat
surrealkv's LSM tree and buffer whole in RAM on every read.

- POST/GET /notes/{id}/files, GET/DELETE /notes/{id}/files/{file_id};
  owner-only through the owning note, staff included
- max_file_bytes in settings (1 KiB-25 MiB hard cap, default 5 MiB),
  enforced on streamed bytes (413), inside the settings CAS guard;
  option<int> so pre-field volumes boot without a backfill
- 10 files per note; deleting a note removes rows first, blobs after,
  so a crash strands at worst an unreachable blob

2026-07-11

✨ feat(core): error taxonomy, field validators, and limitsAhmet Kaan Gümüş · 90effd1
✨ feat(core): error taxonomy, field validators, and limits

Foundations shared by every layer.

constant.rs centralizes the validation bounds — username/password
lengths, free-text caps, the closed sets of attendance statuses and
exam kinds, the mark range, and the session lifetime — so no limit is
hardcoded twice.

error.rs defines ValidationError and the single AppError enum, plus
its IntoResponse: each variant maps to one status code and the uniform
`{ "error": ... }` body. TooManyRequests carries its Retry-After;
Db/Internal are logged and answered generically so no internals leak.
argon2 hashing failures fold into Internal.

validate.rs holds the field validators every newtype's try_new runs
before wrapping a value — parse, don't validate. Lengths are counted
in characters, not bytes, and usernames are trimmed first so padding
can't defeat the minimum.