{"data":{"slug":"discovered-257d2dbf081b3af2f7c65759297863e9aa3a473431c85d6f","title":"Roblox Profile Lifecycle And Session Ownership","summary":"Design server-authoritative player profile loading, exclusive session ownership, lease renewal, and safe release to prevent simultaneous writable profile sessions and stale-server overwrites.","url":"https:\/\/skillshunter.net\/skills\/discovered-257d2dbf081b3af2f7c65759297863e9aa3a473431c85d6f","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-257d2dbf081b3af2f7c65759297863e9aa3a473431c85d6f","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-257d2dbf081b3af2f7c65759297863e9aa3a473431c85d6f.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-257d2dbf081b3af2f7c65759297863e9aa3a473431c85d6f\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Implement a unique server-session token, not a client-provided identifier. Before saving or releasing, verify the owner token still matches to prevent stale server overwrites. Use a custom wrapper or adapt Roblox's `SessionLockedDataStoreWrapper` with thorough testing.","instructions":"---\nname: roblox-profile-lifecycle-and-session-ownership\ndescription: Design server-authoritative player profile loading, exclusive session ownership, lease renewal, and safe release.\n---\n\n# Roblox profile lifecycle and session ownership\n\n## Goal\nPrevent simultaneous writable profile sessions, stale-server overwrites, and unsafe loading after an ambiguous lock result.\n\n## Lifecycle\n1. Review Roblox's current `DataStoreWrapper` and `SessionLockedDataStoreWrapper` reference implementation first. It demonstrates per-key request ordering\/retries and session locks. The Creator Hub warns that its sample has not been proven at scale; do not copy it unchanged. Adapt and test it thoroughly, or implement the same ownership invariants in a reviewed custom wrapper.\n2. Define one profile owner service and one well-defined profile state machine: unloaded, loading, active, saving, releasing, failed.\n3. Acquire the session lease through an UpdateAsync transform using a unique owner token and bounded expiry.\n4. Never make a profile writable unless both its data and session ownership are confirmed.\n5. On contention, wait with a bounded policy or fail closed. Do not load a second copy and continue saving.\n6. Refresh the lease with a non-yielding transform that verifies the current owner token.\n7. Before save\/release, verify the owner token still matches. A stale server must never clear or overwrite a newer session.\n8. On PlayerRemoving, save and release only that session's lock.\n9. On BindToClose, flush active profiles concurrently within a bounded shutdown budget and stop accepting new mutations.\n\n## Failure cases\nSpecify behavior for timeouts, ambiguous reads, expired leases, server crashes, duplicate joins, teleports, and lock-renewal failures. If ownership becomes uncertain, freeze mutations and use a safe recovery flow instead of guessing.\n\n## Required deliverables\nProfile state machine, lock record contract, ownership invariants, stale lease policy, retry policy, reconnect behavior, and race-condition test matrix.\n\n## Non-negotiable safeguards\n- Server owns all persistent mutations.\n- Use a unique server-session token, not a client-provided identifier.\n- Release only a lock owned by the current session.\n- Keep per-key writes serialized.\n- Test with multiple servers in a separate test experience.\n","use_cases":["Implementing server-authoritative player profile loading with lease renewal","Designing exclusive session ownership to prevent simultaneous writes","Creating a safe release mechanism for profile sessions","Testing race conditions and lease expiration policies"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/Aziz24666\/Codex_Roblox_skills\/blob\/eb2be117f63d6442c0f9b6d9d38bbdd7adf9374c\/v40\/skills\/roblox-profile-lifecycle-and-session-ownership\/SKILL.md","source_commit":"eb2be117f63d6442c0f9b6d9d38bbdd7adf9374c","license":null,"version":null,"listing_approved_at":"2026-11-30","created_at":"2026-11-29T11:08:36.000000Z","updated_at":"2026-11-30T06:52:12.000000Z","seo_title":"Roblox Profile Lifecycle and Session Ownership Design","seo_description":"Design server-authoritative player profile loading with exclusive session ownership, lease renewal, and safe release to ensure data consistency and prevent conflicts in a","seo_keywords":["roblox profile lifecycle","session ownership","server authoritative data","lease renewal","profile state machine","race condition testing"]}}