fix(539): WorkAheadSlots.Release never publishes a negative count #546

Merged
timothy merged 1 commits from fix/539-workaheadslots-hardening into main 2026-07-21 21:20:43 +02:00
Owner

Hardens the #536 work-ahead slot pool release path (three Low findings from the clamp re-review, unreachable today but filed against a future second release site).

  • §1 Release() clamps before decrementing (CAS loop guarded by current > 0) so it never publishes a negative count even transiently — closing the window where a concurrent TryAcquire reads phantom room and over-admits. Records the unbalanced release synchronously.
  • §3 Release() returns bool; HlsSessionWorker logs a warning on the unbalanced return (in-band signal for a future second release site).
  • §2 UnbalancedReleases doc corrected — it can under-count; no false positives, but zero doesn't prove correctness.
  • Test Release_Unbalanced_NeverPublishesNegativeCount (2M unbalanced releases vs 4 count-samplers) with a verified negative control. Full Core.Tests suite green (631). decisions.md entry added.

Independent cold review: MERGEABLE.

fixes #539

Hardens the #536 work-ahead slot pool release path (three Low findings from the clamp re-review, unreachable today but filed against a future second release site). - **§1** `Release()` clamps *before* decrementing (CAS loop guarded by `current > 0`) so it never publishes a negative count even transiently — closing the window where a concurrent `TryAcquire` reads phantom room and over-admits. Records the unbalanced release synchronously. - **§3** `Release()` returns `bool`; `HlsSessionWorker` logs a warning on the unbalanced return (in-band signal for a future second release site). - **§2** `UnbalancedReleases` doc corrected — it can under-count; no false positives, but zero doesn't prove correctness. - Test `Release_Unbalanced_NeverPublishesNegativeCount` (2M unbalanced releases vs 4 count-samplers) with a **verified** negative control. Full Core.Tests suite green (631). `decisions.md` entry added. Independent cold review: MERGEABLE. fixes #539
Author
Owner

Independent cold adversarial review (concurrency-scoped) of the pushed diff: no correctness/concurrency/vacuity defects. Release() proven never-negative and lock-free, over-admit window closed, test sound with a verified negative control, docs accurate.

Review-verdict: MERGEABLE @ 59b38d4168b9a5d3d6f39812edc465a19e4e2acc

Independent cold adversarial review (concurrency-scoped) of the pushed diff: no correctness/concurrency/vacuity defects. Release() proven never-negative and lock-free, over-admit window closed, test sound with a verified negative control, docs accurate. Review-verdict: MERGEABLE @ 59b38d4168b9a5d3d6f39812edc465a19e4e2acc
Author
Owner

Re-verdict after the catalog regeneration (b70ab546): the only delta from the reviewed head (59b38d41) is one generated row in docs/decisions/README.md from build_decisions_catalog.py — no code or rationale change. Review still holds.

Review-verdict: MERGEABLE @ b70ab546f467ff110ffc5e04c73244c67ce7d601

Re-verdict after the catalog regeneration (b70ab546): the only delta from the reviewed head (59b38d41) is one generated row in docs/decisions/README.md from build_decisions_catalog.py — no code or rationale change. Review still holds. Review-verdict: MERGEABLE @ b70ab546f467ff110ffc5e04c73244c67ce7d601
timothy force-pushed fix/539-workaheadslots-hardening from b70ab546f4 to 1ce5743bc1 2026-07-21 20:59:54 +02:00 Compare
Author
Owner

Rebased on origin/main to resolve the append-only conflict with #541 (both appended a decisions.md entry); kept both entries and regenerated the catalog. Code diff (WorkAheadSlots.cs / HlsSessionWorker.cs / tests) is byte-identical to the reviewed version — only docs/decisions.md + generated README changed. Review holds.

Review-verdict: MERGEABLE @ 1ce5743bc1

Rebased on origin/main to resolve the append-only conflict with #541 (both appended a decisions.md entry); kept both entries and regenerated the catalog. Code diff (WorkAheadSlots.cs / HlsSessionWorker.cs / tests) is byte-identical to the reviewed version — only docs/decisions.md + generated README changed. Review holds. Review-verdict: MERGEABLE @ 1ce5743bc15850279ff7fbe58dfc3c9aed8043c0
timothy scheduled this pull request to auto merge when all checks succeed 2026-07-21 21:00:42 +02:00
timothy merged commit 44d9e47e1c into main 2026-07-21 21:20:43 +02:00
timothy deleted branch fix/539-workaheadslots-hardening 2026-07-21 21:20:44 +02:00
Sign in to join this conversation.