forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to tests/partial_patch_work.rsClear filter

2026-07-25

fix: 🔐 a partial PATCH can no longer invert a rangeAhmet Kaan Gümüş · 352b0b0
fix: 🔐 a partial PATCH can no longer invert a range

- regression from the previous commit: writing only the field a
  request carried meant an event's schedule and a work stint's clock
  were each checked against a stored other end that a concurrent
  request had already changed, so two individually valid PATCHes
  committed starts_at > ends_at (or check_in > check_out), both 200
- the old snapshot refill hid this by always writing a consistent
  pair; the parent commit passes the same attack, this one did not
- add EVENT_LOCK and WORK_ENTRY_LOCK and hold them across
  read → range check → write, but only when a range field actually
  arrives, mirroring what terms already did correctly
- both locks are leaves: their only holders take no other lock and no
  other lock holder takes them, so the documented EXAM → BANK and
  EXAM → HOMEWORK orders are unaffected
- omitted fields are still never written; the lock guards the check,
  it does not license writing back what was only read
- regression tests race one end against the other and assert the
  stored pair is ordered whatever each request returns
fix: 🧩 a PATCH writes only the fields it was givenAhmet Kaan Gümüş · 85b408e
fix: 🧩 a PATCH writes only the fields it was given

- every PATCH handler loaded the row and refilled the fields the
  request omitted from that stale snapshot, so two concurrent partial
  PATCHes touching different fields lost each other: whoever wrote
  last silently reverted a field it was never asked to change
- field-scoping the write did not fix this — the value bound to the
  SET still came from a stale read
- add domain/field_update.rs: .set(column, Option<T>) skips an absent
  field entirely, so it is neither written nor bound, and an all-absent
  PATCH writes nothing at all
- convert notes, events, terms, homework, work entries and courses,
  each with a 20-round concurrent-PATCH regression that fails against
  the old code on round 0 and passes after
- nullable columns stay clearable: an event's schedule, a course's
  capacity and term, and homework's assigned subset keep the
  double-option so an explicit null still writes NONE, while an
  omitted field is left alone
- homework's old fallback was worse than a no-op: it could re-narrow
  the assigned subset over a concurrent widening, behind the guard
  that exists to stop exactly that
- cross-field validation still reads the stored row where it must
  (event and term ranges need both ends) — read for the check, never
  written back
- HOMEWORK_LOCK was taken after the row read, so it never covered the
  read-modify-write it looked like it guarded