forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to Cargo.tomlClear filter

2026-09-15

🆔 fix: one id convention — every id is a v7 uuid, none is a v4Ahmet Kaan Gümüş · d40e4c9
🆔 fix: one id convention — every id is a v7 uuid, none is a v4

The crate mints UUIDv7 from the process-wide monotonic generator, but four
sites still minted a v4:

- ChoiceId (an exam choice's stable id) and the blob names of answer
  images, bank-question images and homework files: now next_uuid(), like
  their siblings (question_image already was)
- test_suffix()'s 5-hex tail is not an id — it is the random half of a test
  database's name — so it draws from the OS rng: a v7's leading hex digits
  *are* the mint time, which is exactly what two processes minting in the
  same millisecond share
- the request-id layer installed tower-http's MakeRequestUuid (a v4); it
  now mints through the crate's own generator, same wire shape

The manifest drops uuid's v4 feature, and a guard test scans src/ so a
stray v4 fails the suite. (tower-http's request-id feature still enables
uuid/v4 in the dependency graph; nothing here calls it.)

2026-09-12

2026-09-07

🐛 fix: OTLP over HTTP exports from the SDK's own threads againAhmet Kaan Gümüş · 1ab3b60
🐛 fix: OTLP over HTTP exports from the SDK's own threads again

The `hyper-client` feature gave every OTLP exporter an HTTP client that
calls `tokio::time::timeout`, but the batch span/log processors and the
periodic metric reader each run on a plain `std::thread` with no reactor
on it. Every export attempt panicked with "there is no reactor running"
— the panic hook then logged it and the batch was dropped, so a
configured collector received nothing at all from any of the three
signals while the process looked healthy.

Swap the client to `reqwest-blocking-client`, which carries its own
runtime and is the client the sync processors expect. reqwest is pulled
with default features off (no extra TLS stack) and was already in the
lock file. Verified end to end against a live collector: spans
(`GET /health`, `GET unmatched`, `POST /builder/login`), the
`http.server.request.duration` histogram and the process's log records
all arrive, with no forbidden attribute keys among them.

Claude-Session: https://claude.ai/code/session_018sqvyBCZ9kpQP6vnGomT2s
✨ feat: OpenTelemetry bootstrap — OTLP traces/metrics/logs, request spans, request idsAhmet Kaan Gümüş · 057a7fa
✨ feat: OpenTelemetry bootstrap — OTLP traces/metrics/logs, request spans, request ids

Telemetry is off unless OTEL_EXPORTER_OTLP_ENDPOINT is set, mirroring the
AI bridge's "off unless configured" shape. With it unset the process logs
exactly as before; every instrument binds to the noop meter provider, so
call sites never branch on whether telemetry is on.

Privacy is the design constraint (KVKK): a span carries the method, the
route TEMPLATE, the status, a random request id and the school slug —
never a user, an IP, a URL path, a body, a header or a cookie.
tests/telemetry.rs fails the build if a forbidden attribute key appears.

New variables (all documented in .env.example):
  OTEL_EXPORTER_OTLP_ENDPOINT   presence turns export on
  OTEL_EXPORTER_OTLP_PROTOCOL   grpc (default) | http/protobuf
  OTEL_EXPORTER_OTLP_HEADERS    read by the SDK
  OTEL_SERVICE_NAME             read by the SDK, defaults hezarfen_backend
  OTEL_TRACES_SAMPLER(_ARG)     read by the SDK, parent-based always-on
  LOG_FORMAT                    pretty (default) | json; anything else refuses to boot
  DEPLOY_ENV                    deployment.environment.name

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

2026-08-12

🤖 feat: let ai services read the api over quicAhmet Kaan Gümüş · b0af858
🤖 feat: let ai services read the api over quic

A service now opens a bidirectional stream of its own, writes one
ApiRequest and reads one ApiResponse: the bridge validates it and
dispatches it into the real router, so a service asks for school data
over the same handlers the REST API serves instead of getting a second
copy of them.

The router is handed over *before* the outer layers, because a synthetic
QUIC request is not a browser request from an IP: it has no address to
bill the per-IP limiter (it would drain the shared unknown-client
budget), and ETag/CORS are browser concerns. That skips the db guard too,
so this path runs the same liveness check and REQUEST_TIMEOUT_SECS
deadline itself.

Validation order is pinned, since it decides what is refused before the
router ever sees it: method (absent or GET) → the AI_API_ALLOWLIST path
→ the principal, loaded live from the database so a stale id cannot act
as a deleted user. Anything the router itself answered — 401, 403, 404
included — rides back as Ok with that status; the Err codes are
bridge-level refusals only: malformed, method_not_allowed,
path_not_allowed, unknown_user, unavailable, not_json, too_large.

The control-stream handshake and the backend→service dispatch are
untouched, and a service that never opens a second stream sees no
difference at all.

2026-07-30

feat: 🎨 sync the accent color like theme and languageAhmet Kaan Gümüş · 9490623
feat: 🎨 sync the accent color like theme and language

The frontend's palette picker kept the chosen accent in localStorage, so
it never followed the user to another device. `palette_color` joins
`theme` and `language` as a third per-user preference: a nullable hex
color on the user row, self-managed and admin-editable through the same
two PATCH routes, `null` until chosen.

The value set is deliberately open — any `#rrggbb` — rather than an enum
of the frontend's palette entries, so adding a palette is a frontend-only
change. Mixed case is accepted and stored lowercase, which is why
`/limits` publishes the accept-set pattern (`^#[0-9a-fA-F]{6}$`) and not
the storage form: a client validating its own input against the published
regex has to agree with the server, and a test now compiles that regex
and runs it over the validator's own accept/reject examples.

2026-07-25

fix: 🏦 choice identity, bank visibility, and whole-row save racesAhmet Kaan Gümüş · ca93ae9
fix: 🏦 choice identity, bank visibility, and whole-row save races

- choices become {id, text} with stable server-minted ids; correct and
  exam_answer.selected name a choice id, and image rows key off it, so
  editing a choice list can no longer re-point an answer key, a picture
  or a student's recorded answer
- a PATCH carrying choices no longer wipes every option picture: it
  drops only rows whose choice id is absent from the new list, and
  omitting choices re-submits the stored ids untouched
- bank templates are private by default; list, read, both image routes
  and from-bank enforce it, and an invisible template 404s rather than
  403s so it cannot be probed for existence
- bank list pages in SQL, newest first, with server-side text and
  visibility filters and a count over the same predicate — it used to
  return the whole table and window it in memory
- text search folds Turkish casing through one shared table used by
  both the Rust needle and the SurrealQL column
- fix: ExamAttempt::finish whole-row-saved a stale struct, so a
  walk-out stamp written by the exam-room socket could be reverted;
  it now writes only finished_at
- fix: BankQuestion::update and Subject::update had the same shape;
  ban it going forward with scripts/check-whole-row-saves.sh and an
  explicit whole-row-save-ok opt-out for rows that cannot be raced
- fix: question_to_bank wrote its back-link holding only BANK_LOCK, so
  a save racing a question edit lost the link
- ids come from the monotonic ULID generator that already existed for
  appointment slots — Ulid::new is not monotonic within a millisecond,
  so newest-first ordering was wrong for same-ms rows
- source_bank splits into from_bank and banked_as; deleting a template
  clears both, deleting a subject clears the template's subject instead
  of blocking the delete
- add refresh-from-bank, frozen once an attempt exists, and a one-query
  per-page usage count
- Exam::delete no longer reads a hardcoded statement slot
- proptest over QuestionSpec::try_new: a key matching a stored choice is
  that choice, any other key is a new option that cannot steal an
  identity

2026-07-24

⬆️ chore(deps): bump all dependencies to latestAhmet Kaan Gümüş · 43e9f86
⬆️ chore(deps): bump all dependencies to latest

Major bumps: axum-extra 0.10→0.12, tower-http 0.6→0.7,
getrandom 0.3→0.4, base64 0.22→0.23, reqwest (dev) 0.12→0.13.
Plus axum 0.8.9, surrealdb 3.2.3, tokio 1.53.1 and transitive
updates via cargo update. No API breakage; full suite green.

Also drop a stale mut in tests/ai_protocol.rs (unused_mut warning).

2026-07-23

✨ feat(chat): relay chatbot over the AI bridgeAhmet Kaan Gümüş · b0aa0a1
✨ feat(chat): relay chatbot over the AI bridge

The backend relays between the frontend and an out-of-process AI service:
it owns auth, rate limiting, persistence and payload format, and may
inspect an answer before the frontend sees it. No rule or intent tables —
conversation is free-form.

Two-phase by design. POST persists the pending assistant row *before*
dispatching, then returns 202, so a reload never loses an answer; the
client either polls the message or opens an SSE stream. Both read the
same DTO, so they cannot disagree. Deltas are sliced from the finished
text because hab/1 is unary — the event shape exists so real streaming
drops in later without a client change.

A turn always settles. Every failure after the rows are written marks the
row failed with a machine-readable code, a boot sweep flips rows orphaned
by a restart, and a pending row older than five minutes reads as timed
out — projected at read, never written back, so a slow-but-alive answer
is not raced. An over-long answer is clipped and flagged rather than
dropped; an empty one fails.

Message ids come from a monotonic ULID generator: the two rows one POST
writes share a millisecond routinely, and a random tie-break rendered the
answer above its own question and handed the service [assistant, user],
breaking the documented oldest-first history contract.

The conversation cap counts and creates under a lock — SurrealDB
BEGIN/COMMIT does not serialize cross-record counts, and 16 concurrent
creators over-admitted a cap of 5 to 20 without it.

Every authenticated role may chat, parents included. Foreign threads are
404, never 403.
✨ feat(ai): QUIC bridge for out-of-process AI servicesAhmet Kaan Gümüş · dc49954
✨ feat(ai): QUIC bridge for out-of-process AI services

The AI features live in separate projects, so they need a transport. QUIC:
each request rides its own bidirectional stream on the service's single
long-lived connection, which puts multiplexing in the transport — no
correlation-id bookkeeping, no head-of-line blocking between concurrent
requests, one handshake instead of one per request.

The backend listens and the services dial in, so a service can sit behind
NAT, restart without the backend knowing its address, and scale out by
opening a second connection (each connection is an independent worker).

Protocol "hab/1", also the ALPN so an incompatible service is refused at the
TLS handshake rather than one frame later. Frames are length-prefixed JSON
(u32 big-endian) because the services will not be Rust; the length is checked
against an 8 MiB cap before any buffer is allocated. The control stream
carries Hello/Greeting and then stays open — its closure is the goodbye, so
there is no heartbeat frame, and a silent death is caught by the QUIC idle
timeout.

Routing is least-inflight rather than round-robin: AI request costs are
wildly uneven, and taking turns would pile a second long inference onto a
busy worker while an idle one sits next to it. Selection and the in-flight
increment happen under one lock so concurrent dispatches cannot overshoot a
worker's declared max_concurrent, which a Lease releases on drop.

Services authenticate with a shared token (constant-time compare); the
certificate only proves the backend, and is self-signed at boot unless a PEM
pair is configured. Since that regenerates per boot, GET /ai/certificate
publishes it (PEM + sha256) for a service to pin — public because a server
certificate is handed to every peer in the TLS handshake anyway, and 404 when
the bridge is off. A service must re-fetch on every reconnect, not once at
startup.

Off unless AI_QUIC_ADDR is set, so the API is unchanged for deployments
without AI. Set without AI_SHARED_TOKEN it refuses to boot rather than listen
unauthenticated.

2026-07-21

✨ feat(db)!: swap embedded surrealkv for a SurrealDB serverAhmet Kaan Gümüş · 60b4509
✨ feat(db)!: swap embedded surrealkv for a SurrealDB server

BREAKING CHANGE: the backend no longer opens a database file. DB_PATH
is gone; DB_URL/DB_USER/DB_PASS point at a SurrealDB server over
WebSocket (compose ships one on surrealkv storage in its own volume,
backend waits on its healthcheck). Pre-switch data was wiped on
purpose — fresh volumes seed from scratch. Tests keep the in-memory
engine; persistence.rs re-runs the boot migration on a live handle
instead of reopening a file.

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-12

✨ feat(exams): scheduled attempts, live monitor, questions, answers, exam roomAhmet Kaan Gümüş · ade4fed
✨ feat(exams): scheduled attempts, live monitor, questions, answers, exam room

- exam scheduling as one validated unit: mode sync|async + window
  (+ per-student duration_ms for async); unscheduled stays offline-graded
- exam_attempt: one row per exam+user by composite id; start = attendance
  signal, finish = submission; status/deadline recomputed from the current
  schedule on every read (mode frozen once attempts exist, times extend live)
- teacher live monitor: GET /exams/{id}/live snapshot + SSE /live/stream
- exam_question: choice|text authored per exam, kind bundle (choices+correct)
  validated as a unit, frozen once attempts start, ULID order
- exam_answer: upsert per question+user via composite id, kind-coherent,
  server-clock stamped; pure auto_score over choice questions as a grading
  suggestion — final mark stays human via /results
- student exam room WebSocket at /exams/{id}/attempt/ws: state ticks,
  autosave acks, finish/expire lifecycle, gates rejected pre-upgrade with
  proper HTTP statuses; shares the REST write path
- PersonRef embeds (id + username + display name) in people-bearing
  responses, plus teacher+ GET /users/search
- cascades: exam/course deletes sweep attempts, questions, answers, results
🐛 fix(time): single UTC clock source, lint-banned alternativesAhmet Kaan Gümüş · 221606f
🐛 fix(time): single UTC clock source, lint-banned alternatives

Timestamp::now() is the sole wall-clock read; today_utc() and
in_days() derive from it. clippy disallowed-methods/-types at deny
ban chrono::Local/Utc::now, SystemTime::now, OffsetDateTime::now_*,
NaiveDateTime, and absolute cookie Expires, so local-time or
client-clock comparisons cannot be reintroduced.

Birth dates accept up to UTC-tomorrow: a client ahead of UTC (up
to UTC+14) legitimately submits a calendar date the server's UTC
day has not reached; the old check rejected it as future.

2026-07-11

🎉 chore: scaffold Cargo project and ignore rulesAhmet Kaan Gümüş · 25233e0
🎉 chore: scaffold Cargo project and ignore rules

Initialize the hezarfen_backend crate on Rust edition 2024.

Runtime stack: tokio + axum 0.8 (axum-extra for cookies, tower-http
for trace/CORS) over an embedded SurrealDB 3 store (surrealkv on disk,
kv-mem for tests). Supporting crates: argon2 password hashing, ulid
record ids, chrono/time instants, thiserror/anyhow errors, tracing,
dotenvy, and utoipa + Swagger UI for OpenAPI docs.

Dev-dependencies cover the test suites: tokio test-util (a paused
clock for the rate limiter), tower oneshot, a reqwest cookie-jar
client, and tempfile.

Cargo.lock is committed — this crate ships a binary. .gitignore
excludes the build dir (/target), the embedded database (/data), and
local secrets (.env).