A session has a number: given at creation, frozen, never reused (#760, D86, lane 4) #807
Loading…
Reference in a new issue
No description provided.
Delete branch "build/760-session-number"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #760. This is lane 4's first server PR (#730). D86: a number, given when the session is created, frozen and never reused; a cancelled session keeps its number, so the sequence has gaps.
Server
Migration
f3a4b5c6d7e8(one1f2a3b4c5d6, single head):campaigns.next_session_numberandsessions.number(NOT NULL) withUNIQUE (campaign_id, number).created_atorder, as #760 asks. A tie, such as an import's sharedcreated_at, is broken by when the session took place. Cancelled sessions are numbered.A counter, not
max + 1, so a deleted newest session's number is never reused. OneUPDATE … RETURNINGin the creating transaction, whose row lock serialises concurrent creates.session_numbering.allocate_session_numberis called by:create_session(and the one-shot);A
before_flushsafety net numbers any other ORM-created session from the same counter. That covers a future creation path, the eval seed and test fixtures.Import and export: export writes
number. Import keeps valid, unclaimed numbers, numbers the rest in the backfill's order, and leaves the counter above them all.numberis exposed on:session_number);It is also on
/api/bot/*, additively: no contract bump, and the bot is untouched.The UI: "Session 14" where the drawing is tight
Everything goes through
sessionLabel()invocabulary.js:Session 14 · Editing it · The Amberwake Accord · Quest Board);This week · Session 14above the title heading);Journeys
This week · Session 3.Checks
Not in this PR
docs/API.mddoesn't list the new fields.Lane 4's page PRs pick these up.
🤖 Generated with Claude Code