coder13 / coder13/LetsCube

Centralize room, RaceSession, attempt, and solve persistence

Offen
#204 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: data area: platform area: results enhancement priority: P1
Vorherrschende Sprache
JavaScript
Sterne
30
Forks
9
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Part of #199.

## Goal

Stop Socket.IO handlers and Mongoose document methods from directly owning room/session/result persistence behavior. Put the aggregate behind a single tested service/repository boundary that can use PostgreSQL authoritatively.

## Scope

Create explicit operations for at least:

- create room and initial race session;
- load room and active/selected session;
- join, leave, ban, and unban;
- assign owner/admin and session control roles;
- create, start, pause, end, and switch race sessions;
- create the next attempt;
- submit and edit an idempotent solve;
- hide, archive, or delete a room according to the retention contract.

Socket handlers should authorize and translate protocol messages, then call these operations. They should not directly mutate embedded attempts, result maps, or room event state.

## Requirements

- Preserve the current Socket.IO protocol during the first phase where practical.
- Preserve idempotent submission IDs and immutable attempt keys.
- Use PostgreSQL transactions wherever one user action changes room, session, attempt, participant, and solve state together.
- Keep authorization inside or immediately adjacent to the domain operation so alternate callers cannot bypass it.
- Define repository implementations or feature flags needed for migration comparison and rollback.
- Emit realtime events only after durable writes succeed.
- Keep chat transport outside this persistence scope unless required by the contract.

## Acceptance criteria

- [ ] All room/session/attempt/solve mutations have explicit service operations.
- [ ] Socket handlers no longer directly mutate the persisted aggregate.
- [ ] Result submission remains idempotent across reconnects and retries.
- [ ] Event changes end/create sessions without deleting history.
- [ ] Transactions prevent partially-created sessions, attempts, or solves.
- [ ] Authorization tests cover owner, admin, participant, banned, anonymous, and stale-session cases.
- [ ] Existing normal-room client behavior and protocol tests continue passing.
- [ ] The persistence boundary supports shadow comparison and an authoritative PostgreSQL mode.

## Dependencies

- Domain contract and PostgreSQL expansion schema from this initiative.
- Preserve the ownership/admin contract established by #195.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Finde die Socket.IO-Handler und Mongoose-Dokumentmethoden, die derzeit rooms, sessions, attempts und solves verändern, und lies anschließend die zugehörigen Protokolltests und das PostgreSQL-Erweiterungsschema. Die Arbeit ist abgeschlossen, wenn explizite Service-Operationen diese Veränderungen übernehmen, Transaktionen und Autorisierung durch Tests abgedeckt sind, Realtime-Ereignisse dauerhaften Schreibvorgängen folgen und das Protokollverhalten für normale Räume weiterhin erfolgreich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, mongodb, nodejs, postgresql
Bereich
backend, databases
Issue-Typ
Refactoring
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.