Add SQLite-backed server-side sessions with explicit lifecycle and bounds
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Empieza leyendo las APIs existentes de pool bounded de Sqlite.Db, transacciones, timeouts y errores tipados, junto con Random.bytes! y el módulo de cookies tipado de las dependencias #198 y #199. Define el ciclo de vida de Session en torno a las operaciones create, load, rotate, invalidate y prune indicadas, y después cubre las pruebas requeridas de concurrencia, expiración, límites, reinicio, rollback y diagnóstico de SQLite. Se considera terminado cuando haya sesiones bounded duraderas, una política de cookies explícita y se cumplan todos los criterios de aceptación.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Add a Session module implemented over the existing bounded SQLite pool. The browser receives only an opaque bearer identifier; application session data remains in SQLite.
Illustrative API:
store = Session.init!({
db,
max_payload_bytes: 16 * 1024,
idle_timeout_seconds: 30 * 60,
absolute_timeout_seconds: 24 * 60 * 60,
})?
created = Session.create!({ store, now, payload })?
loaded = Session.load!({ store, now, id })?
rotated = Session.rotate!({ store, now, id })?
Session.invalidate!({ store, id })?
Session.prune!({ store, now, max_rows: 500 })?
Dependencies
- #198 for OS-backed cryptographic random bytes
- #199 for typed request cookies and secure
Set-Cookierendering
Why this belongs in the platform
Server-side sessions are a conventional web framework facility and fit the platform's explicit preference for durable domain state in SQLite rather than arbitrary mutable process-local state.
The existing Sqlite.Db already provides bounded pooling, timeouts, typed errors, and transactions. The session facility can therefore be a Roc module over SQLite rather than a new host subsystem.
Required contract
- Depend on
Random.bytes!and the typed cookie module. - Generate identifiers from at least 32 OS-random bytes.
- Encode them as a fixed, validated cookie-safe representation.
- Make the identifier opaque and redact it from normal inspection.
- Store only a one-way digest of the bearer identifier in SQLite.
- Store application data as a bounded
List(U8)payload; serialization is application policy. - Use a fixed, namespaced, versioned table schema.
- Schema creation or migration occurs only through an explicit
Session.init!call. - Enforce idle and absolute expiry server-side.
- Atomically rotate the identifier and invalidate the old identifier to prevent session fixation.
- Support explicit invalidation/logout.
- Provide bounded pruning rather than a detached cleanup worker.
- Use SQLite transactions for each lifecycle operation.
- Document that session operations are not automatically atomic with arbitrary application-table updates in the first version.
- Return typed missing, expired, malformed, saturated, timeout, and SQLite failures.
- Never use an in-memory session cache as the source of truth.
The cookie helper should be used to emit an explicitly configured Secure, HttpOnly, SameSite cookie. The session module should not guess whether the public deployment uses HTTPS.
Tests
- Create, load, update, rotate, invalidate, and expire.
- Idle versus absolute expiry.
- Concurrent loads, rotations, and invalidations.
- Old identifier unusable immediately after rotation.
- Payload exact-limit and over-limit behavior.
- Bounded prune batches.
- SQLite busy, timeout, and rollback paths.
- Restart and multi-process behavior against the same database.
- No identifier values in diagnostics.
Non-goals
- Users, authentication, roles, or authorization
- In-memory sessions
- A generic key/value map with hidden serialization
- Client-side encrypted session cookies
- Background cleanup jobs
- Automatic session creation on every request
- Flash messages or login redirects
Acceptance criteria
- Session state is durable SQLite state, not process-local mutable state.
- Identifiers are cryptographically random, opaque, rotated, and explicitly invalidated.
- Idle and absolute timeouts are enforced by the server-side store.
- Payload, queries, and cleanup work are bounded.
- Cookie policy remains explicit at the application boundary.
- Concurrency and restart behavior are covered by real SQLite tests.
References
- Lenguaje dominante
- HTML
- Estrellas
- 110
- Forks
- 25
- Merge medio
- 18 h 28 min
- PR fusionados (30 d)
- 16
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de roc-lang/basic-webserver
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
roc-lang/basic-webserver#277 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
roc-lang/basic-webserver#274 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
roc-lang/basic-webserver#273 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
roc-lang/basic-webserver#272 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
roc-lang/basic-webserver#265 ·
Los mantenedores suelen responder en 1 día
Todos los issues de roc-lang/basic-webserver
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
OHDSI/Data2Evidence#3815 ·
Los mantenedores suelen responder en 3 días
-
e2e-failure ready-to-code
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
redhat-developer/rhdh-plugin-export-overlays#4995 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
fidelity
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hostsPosiblemente ocupada @huanghaoyuanhhy la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
zilliztech/milvus-backup#1418 ·
Los mantenedores suelen responder en 1 día
-
[Bug] download repeatedly fetches unchanged gzip responses due to compressed/decoded size mismatchPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
stanfordnlp/dspy#11000 ·
Los mantenedores suelen responder en 1 día