Commits
2026-09-25
🧹 chore(rate-limit): raise the shipped budgets 100xAhmet Kaan Gümüş · 51e5c7b
🧹 chore(rate-limit): raise the shipped budgets 100x Default budgets when the env is unset: auth 1000/min per IP, API 30000/min per IP, chatbot 2000/min per user, RAG 600/min per user, keyless overflow 60000/min. An explicit RATE_LIMIT_* still wins. The per-route enforcement census uses a small census budget so CI does not hammer 30000 requests per route; production-scale boundary stays in the in-memory limiter tests.
2026-09-23
✨ feat: school identity is the uuid; drop the slugAhmet Kaan Gümüş · 2918040
✨ feat: school identity is the uuid; drop the slug
The school slug is gone from every surface: the session cookie prefix,
the /schools/{id} builder routes, FILES_PATH blob dirs, the hab/2 frame
school value, DTOs, and the /limits contract. SchoolId::try_parse is the
one wire parse (hyphenated uuid only); a non-uuid frame school answers
unknown_school. Register gets a public picker via the new unauthenticated
GET /auth/schools returning active [{id, name}]. The control migration
drops school_slug and the slug column, which invalidates every existing
session — old cookie prefixes cannot resolve.
Local-Gate: 3fafffd98aec59c68e2606833b87785d0abf2fee (1510 passed, 425s)2026-09-17
✨ feat: add the /rag nest over the course-note RAG bridgeAhmet Kaan Gümüş · a61e0a6
✨ feat: add the /rag nest over the course-note RAG bridge A separate rag_thread/rag_message pair of tables and a Module::Chatbot gated /rag nest, mirroring the chatbot's asynchronous send: POST answers 202 with a pending assistant row, an in-process task settles it, and both the poll read and the SSE stream project a stale pending row as failed. Every question is scoped server-side to the asker's own (sinif, ders) pairs — class-section instances, a linked parent's children, school-wide club/study memberships — never from the body. Each citation's corpus doc_id is resolved per candidate to a course-note file the asker may view, and the two storage caps refuse an over-bound reply whole rather than clipping it. rag.index replies now stamp each file's rag_doc_id, the missing link between a citation and its file. The chatbot's SSE helpers move to web/mod.rs so both nests stream through one implementation, and the instance/course visibility gates move from web to service so the scope deriver and the routes share one rule. Gates: cargo check --all-targets, clippy -D warnings, limits_completeness, spec_bounds, doc_sync (README regenerated), protected_routes_require_session (MIN_PROTECTED 269 -> 318, the real swept count), ai_bridge (75 tests).
2026-09-14
✨ feat: mint OpenObserve OTLP Basic from ZO_ROOT_USER_*Ahmet Kaan Gümüş · 9ce59bf
✨ feat: mint OpenObserve OTLP Basic from ZO_ROOT_USER_* When OTEL_EXPORTER_OTLP_ENDPOINT is set and HEADERS is not, the process builds Authorization=Basic from ZO_ROOT_USER_EMAIL/PASSWORD. No hand base64 in the env file.
🔧 chore: default HTTP bind port 7656Ahmet Kaan Gümüş · 81ac0fb
🔧 chore: default HTTP bind port 7656 Unset PORT now binds 7656 instead of 8080: parse_port, the user unit, compose, Containerfile, CI health-gate fallback, and README.
2026-09-13
🗃️ feat: VPS deploy workflow + exe-relative migrations + CORS anywhere modeAhmet Kaan Gümüş · b2780eb
🗃️ feat: VPS deploy workflow + exe-relative migrations + CORS anywhere mode
- .github/workflows/main.yml: im-style deploy on push to main — pinned
ubuntu-24.04 runner, Postgres sidecar (max_connections=500) for the
per-test-database suite, clippy -D warnings + full nextest gate,
--release build under SQLX_OFFLINE, SSH release-dir swap + systemd user
unit restart, /health gated on THIS build's process (MainPID exe) with
rollback, independent after-the-fact verify.
- deploy/hezarfen.service: the shipped user unit; secrets and deployment
knobs live in ~/hezarfen/hezarfen.env on the server (never in-repo).
- migrations_path: fall back to migrations/ beside the executable when the
compile-time CARGO_MANIFEST_DIR path is absent — a deployed binary was
looking for its schema on the build machine and aborting boot.
- CORS_ALLOWED_ORIGINS=*: anywhere-mode, every origin mirrored WITH
credentials ("allow CORS to anywhere for now"); SameSite=Lax stays the
cross-site guard. Default mirror mode unchanged; test pins star mode.2026-09-12
2026-09-07
✨ 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-09-05
✨ feat: one database per school behind a control registry; login names the schoolAhmet Kaan Gümüş · b7dfc0c
✨ feat: one database per school behind a control registry; login names the school Namespace `hezarfen` now holds one DATABASE per school (name = slug) plus a `control` database with the school registry, builder accounts and builder sessions. `Tenants` keeps one separately-connected handle per school; the shadow `web::tenant_state::State` resolves the school from the `<slug>.<token>` cookie so every handler's `st.db` is school-scoped by construction. `POST /auth/login` / `register` carry `school`; a suspended school answers 403 everywhere. `BUILDER_USERNAME`/`BUILDER_PASSWORD` seed the vendor account; the boot admin seed is gone. No customers, no compat shims.
2026-07-23
🎨 style(chatbot): rename thread/message off the mail collisionAhmet Kaan Gümüş · 92b232b
🎨 style(chatbot): rename thread/message off the mail collision
The AI chatbot's storage and web layer reused "conversation" and
"chat_message", the latter one underscore away from the human-to-human
mail `message` feature — every reader had to disambiguate two unrelated
tables by eye.
Rename the whole chatbot feature to a `chatbot_*` vocabulary:
conversation -> chatbot_thread (ChatbotThread*, CHATBOT_THREAD_*)
chat_message -> chatbot_message (ChatbotMessage*, CHATBOT_MESSAGE_*)
/chat/conversations -> /chatbot/threads
max_chat_conversations -> max_chatbot_threads
max_chat_message_len -> max_chatbot_message_len
chat_history_turns -> chatbot_history_turns
RATE_LIMIT_CHAT_PER_MINUTE -> RATE_LIMIT_CHATBOT_PER_MINUTE
DTO conversation_id -> thread_id
The out-of-process AI-service wire contract is deliberately untouched:
ai/chat.rs payload types, AI_CHAT_CAPABILITY ("chat.reply"), the serde
field names and the hab/1 ALPN stay as-is — other-language services
match on those literals. ai/chat.rs remains "the chat.reply payloads",
a separate concern from the chatbot feature it feeds.
Clean break, no row migration (pre-customer, FE not yet synced): old
conversation/chat_message rows in the volume are abandoned. Frontend
must adopt the new routes, the thread_id field, and the renamed
settings keys.✨ 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-18
🔒 fix(cors): never send credentials in mirror modeAhmet Kaan Gümüş · 6faa816
🔒 fix(cors): never send credentials in mirror mode Unset CORS_ALLOWED_ORIGINS reflected any origin AND advertised allow-credentials — a credential-theft hole held shut only by the cookie's SameSite=Lax, two independent switches guarding one door. Mirror mode (dev) now runs uncredentialed; the allowlist branch keeps credentials. cors_layer takes the allowlist as a parameter (env read once in build_router) so tests drive both modes without env races. Boot warns when COOKIE_SECURE is on without an allowlist. Cookie-using browser frontends must list their origin in CORS_ALLOWED_ORIGINS — including cross-port localhost dev setups.
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 blob2026-07-11
✨ feat(admin): seed an admin account at startupAhmet Kaan Gümüş · ea497d9
✨ feat(admin): seed an admin account at startup ADMIN_USERNAME and ADMIN_PASSWORD (both-or-neither; half a pair aborts boot, blank counts as unset) create an admin at startup when the username doesn't exist. The seed is idempotent and never rewrites credentials: an existing admin is left as-is, and a non-admin holding the name is never promoted — that would be a privilege escalation, so it only logs a warning pointing at the out-of-band paths. compose.yaml ships local-dev credentials for first boot; .env.example documents the knob.
✨ feat(config): environment-sourced runtime configurationAhmet Kaan Gümüş · d6dd881
✨ feat(config): environment-sourced runtime configuration Config::from_env reads host/port, the embedded DB path + namespace, the cookie Secure toggle, and the rate-limit tiers. Every value has a safe default, so the server boots with no .env at all. Parsing is lenient: unset or garbage falls back to the default, an explicit 0 rate limit is honoured (disables that tier), and boolean flags accept 1/true/yes/on in any case. main loads .env via dotenvy. .env.example documents every knob, including the production-only COOKIE_SECURE, CORS_ALLOWED_ORIGINS, rate limits, and TRUST_PROXY.