forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/web/etag.rsClear filter

2026-07-26

chore: 📦 give every constant one homeAhmet Kaan Gümüş · 78b25b5
chore: 📦 give every constant one home

Constants were scattered across 18 modules: table names and migration SQL in
database.rs, limits in config.rs and rate_limit.rs, magic strings sitting next
to the only code that read them. Nobody could answer "what are all the hard
values in this service?" without a grep.

They all live in constant.rs now — validation bounds, the 37 SurrealDB table
names, the PRE_REPAIR/MIGRATION/BACKFILL schema SQL, and the enum value tables
that used to hide as associated consts (Role::ALL -> ROLES, Folder::SENDER ->
SENDER_FOLDERS, and friends). Values are byte-identical; this changes no
behavior. constant.rs now imports crate::domain for the enum types, an
intra-crate cycle that compiles fine.

Statics stayed where they were. A Mutex or a ULID generator is runtime state,
not a constant, and moving them would only blur that line.

Two guards keep the consolidation honest. limits_completeness.rs already
failed on any pub const in constant.rs that is neither published through
/limits nor excluded with a reason; the *_TABLE names are excused by shape
rather than by 37 lines of boilerplate, but the excuse now requires the
absence of a MAX_/MIN_/DEFAULT_ prefix so a real bound cannot hide behind the
naming convention. And the move quietly dropped three rules off the end of the
text-fold table, which every existing test still passed — so the circumflexed
vowels are pinned, and search_fold_sql must emit one string::replace per rule
or the needle and the column drift apart.

2026-07-25

fix: ⚡ compare If-None-Match weakly, as RFC 9110 requiresAhmet Kaan Gümüş · ef7becd
fix: ⚡ compare If-None-Match weakly, as RFC 9110 requires

276904c compared validators strongly, but RFC 9110 §13.1.2 says a
recipient MUST use the weak comparison function for If-None-Match. A
`W/"<tag>"` request got a full 200 where a 304 was required, so any
intermediary that weakens ETags on compression — nginx does — silently
turned the whole feature off and every poll re-sent its payload.

`matches()` now strips a leading `W/` from both the candidate and the
stored tag before comparing the opaque parts. Everything else is
untouched: `*`, comma lists, unquoted and malformed values, the layer
position, and the 304 wire form all behaved correctly already.

Vary: Cookie deliberately not added — CorsLayer already owns that
header, so doing it right needs append-and-dedup rather than an insert,
and `private` plus a body-hash validator already means a cross-user 304
can only fire on byte-identical bodies.
🎨 style: cargo fmt the tree before the audit fixesAhmet Kaan Gümüş · b4a5a00
🎨 style: cargo fmt the tree before the audit fixes

Pure reformatting, no behaviour change: rustfmt wrapping plus its
alphabetical `use`-list reordering across the files that had drifted.
Kept separate so the correctness commits that follow carry only logic.

2026-07-24

feat: ⚡ ETag conditional GET so polled reads become cheap 304s - add src/web/etag.rs: global axum middleware on the top-level router (innermost layer) that, for GET + 200 + application/json responses, hashes the body (SipHash, no new dep) into a strong ETag and sets Cache-Control: private, no-cache so the browser revalidates - matching If-None-Match returns 304 with an empty body and the validators kept; frequent frontend polls stop re-sending full payloads - passthrough untouched for non-GET, non-200, non-JSON (image blobs keep their own no-store), and streaming/oversized bodies (size_hint guard) - defensive: a handler that sets its own ETag is passed through without our hash/304 logic, and an existing Cache-Control is never overwritten - responses rebuilt via into_parts/from_parts so Set-Cookie and other handler headers survive on both the 200 and 304 paths - tests/etag.rs: ETag present + revalidation, matching validator → 304 empty, mutations never ETagged, handler-owned headers preservedAhmet Kaan Gümüş · a962778
feat: ⚡ ETag conditional GET so polled reads become cheap 304s
- add src/web/etag.rs: global axum middleware on the top-level router
  (innermost layer) that, for GET + 200 + application/json responses,
  hashes the body (SipHash, no new dep) into a strong ETag and sets
  Cache-Control: private, no-cache so the browser revalidates
- matching If-None-Match returns 304 with an empty body and the
  validators kept; frequent frontend polls stop re-sending full payloads
- passthrough untouched for non-GET, non-200, non-JSON (image blobs keep
  their own no-store), and streaming/oversized bodies (size_hint guard)
- defensive: a handler that sets its own ETag is passed through without
  our hash/304 logic, and an existing Cache-Control is never overwritten
- responses rebuilt via into_parts/from_parts so Set-Cookie and other
  handler headers survive on both the 200 and 304 paths
- tests/etag.rs: ETag present + revalidation, matching validator → 304
  empty, mutations never ETagged, handler-owned headers preserved