Commits
2026-09-12
2026-09-11
2026-07-30
fix: 🔁 retry a guarded cascade that loses a write raceAhmet Kaan Gümüş · 616a66b
fix: 🔁 retry a guarded cascade that loses a write race A BEGIN/COMMIT delete that lost a write conflict answered 500 instead of the refusal or retry it owed. An aborted transaction errors *every* slot, and all but the failing one say a generic "not executed" — the consequence of the abort, never a reason of its own. Picking one of those out of the unordered HashMap from take_errors, or taking the first via check(), retired a retryable round as a database error. Measured on Course::delete at 1-3 of 20 raced rounds against a real server. transaction_with_retry is write_with_retry's story for the cascades that cannot be one statement: it matches the caller's THROW markers first, since a THROW is a decision and outranks a conflict, then re-sends while any slot reports a lost round. It hands back both the response and the drained errors because take_errors consumes and the caller needs the slots as well as the map. Course, Subject and Exam route through it; Exam also loses the check() that was masking the conflict behind a sibling slot. Term needed none of it — it is a single statement, so the existing write_with_retry was the whole fix. Four ignored race tests come with it. Only the course one discriminates, proven by cutting the retry loop to a single attempt and watching it go red; the other three guard their handlers' status codes and say so on themselves rather than implying a measurement they do not make. They share a lock so the documented invocation works.
fix: 🧊 freeze a fee plan the moment it is assignedAhmet Kaan Gümüş · ac70cc0
fix: 🧊 freeze a fee plan the moment it is assigned The 409 that stops an assigned plan being edited or deleted was a scan followed, some microseconds later, by the write it licensed. An assign landing in that gap left a plan edited and assigned, or deleted with a live assignment still naming it. The comment called it an accepted race and blamed the other replica; there was never another replica, and two concurrent requests in one process were always enough. A plan now carries an assignment refcount. The assign claims it in the same transaction that writes the row, and the edit and the delete are conditional writes that refuse while it stands. The plan freezes at the instant of the claim, so the assign re-reads it afterwards and bills the copy that froze — the refcount alone still let an edit slip in front and bill the snapshot the handler had read. Existing plans are seeded from the assignments they already carry. An absent counter reads as zero, which is the value that licenses an edit, so a plan assigned before this would otherwise have come unfrozen. Two things this uncovered. A cap claim that lost a write conflict was answered as a 500 five times in six: the retryable conflict shared the error batch with the sibling statements it aborted, and an arbitrary one of those was returned. And a guarded write had no retry at all, so a raced PATCH or DELETE failed outright rather than trying again. The race tests run against a real server. On the embedded engine they watched a 45-in-50 failure rate and passed.
chore: 🧹 drop the coordination for replicas we never runAhmet Kaan Gümüş · a9cfe7b
chore: 🧹 drop the coordination for replicas we never run The backend runs as one process against one database, deployed stop-the-world. The machinery that let several of them agree was built ahead of a multi-replica rollout that stayed parked, so none of it was ever load-bearing: the boot lease elected a leader out of a field of one, the ai_worker table announced a worker to nobody, and the chat claim queue only ever claimed its own writes. Boot now migrates and seeds straight-line; a chat turn is dispatched by the handler that accepted it; the 503 gate reads the in-process registry. The retired columns and tables are unset and removed in separate batches, repair before REMOVE. What stays, with its reason corrected rather than removed: cap.rs, field_update.rs, the refcounts, the CAS retry loops and the in-process locks. Those close write skew between concurrent requests inside one process, which two replicas made worse but never caused. A turn orphaned by a restart or a panic is no longer reclaimed. It settles as timed_out within CHATBOT_PENDING_STALE_SECS. The design survives in the ledger if a second process is ever wanted.
2026-07-29
feat: 💰 track school fees in an append-only ledger of fee plansAhmet Kaan Gümüş · 740e96a
feat: 💰 track school fees in an append-only ledger of fee plans
Fee plans (name + 1..60 installments of {amount_minor, due_at}) are
assigned directly to students; assignment appends every installment as
a charge at once, keyed <plan>_<student>_c<n> so a replay bills nobody.
Payments target one charge, refunds target one credit, and a reversal
undoes only the negative-fold kinds — a mistaken credit is corrected by
a refund, never edited. Balance is never stored; the over-payment cap
folds the target's source subtree under PAYMENT_LOCK and stays advisory
across replicas, which the module doc states outright.
Meal money is untouched: two ledgers, two balances, one shared amount
vocabulary.