Repository navigation
feat(relay): step-5 reserve core: the cell's booking book and the director's placer (inert) - #27038
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The placement helper has a failure path that should be fixed before it is connected to live requests. No production caller was found, so current live traffic is not affected. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
3cb5641d-8a9e-4d78-ba16-c676b7022f08
📒 Files selected for processing (2)
cloud/apps/relay/src/reserve-placement.test.tscloud/apps/relay/src/reserve-placement.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| calls += 1 | ||
| const answer = await input.reserve(cell.cellId, epoch) | ||
| if (answer.outcome === 'ok') return { kind: 'placed', cellId: cell.cellId, epoch, calls } | ||
| this.uncountBooking(cell, countedAt) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Roll back bookings when a reserve call rejects.
If input.reserve rejects on a transport failure, place skips uncountBooking and never reaches database fallback. The failed attempt also remains in the seat estimate until it expires or a poll clears it. Catch the rejection, roll back that attempt, and handle it as an unreachable outcome. Add a rejection case to the placement tests.
1368e38 to
e505a90
Compare
…ector's placer (inert) Rebased onto main as one commit after its parent squash-merged.
2f27605 to
2feef9e
Compare
ELI5
Step 5 takes desktop connections off the database: a director asks a cell to hold a seat, and the cell says yes or no itself. This PR adds only the two decision-makers as pure code — the cell's booking book and the director's placer — with nothing calling them yet.
What Changed
cell-reserve-contract.ts: the v1 wire forPOST /internal/reserve(batched items,dryRun, per-itemok/full/intake/draining/off/seated-newer {epoch}) andPOST /internal/demote(names one seat by epoch andjoinedAt). Readers are lenient: an unknown outcome counts as a no.cell-reserve-book.ts: the cell's authority. One event loop makes "check cap and budget, then count the booking" atomic. A booking holds a connection unit until its hello consumes it or its 30 s TTL ends; a token bucket (burst 20) enforces the intake rate; a post-restart sticky re-booking skips the bucket but never the cap; a lower-epoch booking hands its unit to its successor.reserve-placement.ts: the director's estimate. Candidates are switched-on, polled within 3 s, general, not draining, with an estimated seat and budget. Power of two choices, at most 3 reserve calls, re-mint above aseated-newer, then the database path, pacing (503 + Retry-After 1–10 s) or spill. Each director assumes 1/5 of each cell's intake and starts empty after a restart. Also the epoch mint and deterministic demotion: the newest cell-reported join wins (ties: higher epoch, then lower cell id); a seat is demoted once it has been outranked for the grace period, so a host flapping across cells cannot keep an old seat alive.No behaviour changes: nothing imports these modules yet.
Why
Both sides must be exactly the code the simulation (next PR) drives, so they are pure, I/O-free modules. Design:
DESIGN-step5-placer-2026-10-09.mdrev 2 (no placer services).Linked Issue
N/A (internal relay redesign, step 5).
Visual Proof
N/A: server-side, no UI.
Testing
cell-reserve-book.test.ts,reserve-placement.test.ts(cap, intake refill, seated-newer, sticky, consume-once, off/draining/dryRun, three-try cap, re-mint, pacing bound, candidate filters, own-booking count, pool share, demotion order).pnpm typecheckand the relay suite pass locally.Notes
Ships dark. Stack: this PR → simulation, cell reserve mode, director placement, ledger writer, census.
Stacked on #27057 (so the cell-flags.ts switches from both land without a conflict). Merge order: #27049, #27057, then this stack.